Graphviz
13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
dtflatten.c
Go to the documentation of this file.
1
#include <
cdt/dthdr.h
>
2
#include <stddef.h>
3
4
/* Flatten a dictionary into a linked list.
5
** This may be used when many traversals are likely.
6
**
7
** Written by Kiem-Phong Vo (5/25/96).
8
*/
9
10
Dtlink_t
*
dtflatten
(
Dt_t
* dt)
11
{
12
Dtlink_t
*t, *r, *list, *
last
, **
s
, **ends;
13
14
/* already flattened */
15
if
(dt->
data
.
type
&
DT_FLATTEN
)
16
return
dt->
data
.
here
;
17
18
list =
last
=
NULL
;
19
if
(dt->
data
.
type
&
DT_SET
)
20
{
for
(ends = (
s
= dt->
data
.htab) + dt->
data
.
ntab
;
s
< ends; ++
s
)
21
{
if
((t = *
s
) )
22
{
if
(
last
)
23
last
->right = t;
24
else
list =
last
= t;
25
while
(
last
->right)
26
last
=
last
->right;
27
*
s
=
last
;
28
}
29
}
30
}
31
else
if
((r = dt->
data
.
here
))
// if (dt->data.type & (DT_OSET|DT_OBAG))
32
{
while
((t = r->left) )
33
RROTATE
(r,t);
34
for
(list =
last
= r, r = r->
right
; r;
last
= r, r = r->
right
)
35
{
if
((t = r->left) )
36
{
do
RROTATE
(r,t);
37
while
((t = r->left) );
38
39
last
->right = r;
40
}
41
}
42
}
43
44
dt->
data
.
here
= list;
45
dt->
data
.
type
|=
DT_FLATTEN
;
46
47
return
list;
48
}
last
static agxbuf last
last message
Definition
agerror.c:29
DT_SET
#define DT_SET
Definition
cdt.h:120
dtflatten
Dtlink_t * dtflatten(Dt_t *dt)
Definition
dtflatten.c:10
dthdr.h
DT_FLATTEN
#define DT_FLATTEN
Definition
dthdr.h:18
RROTATE
#define RROTATE(x, y)
Definition
dthdr.h:35
NULL
node NULL
Definition
grammar.y:163
Dtdata_t::here
Dtlink_t * here
Definition
cdt.h:73
Dtdata_t::type
int type
Definition
cdt.h:72
Dtdata_t::ntab
int ntab
Definition
cdt.h:78
dt_s_
Definition
cdt.h:100
dt_s_::data
Dtdata_t data
sharable data
Definition
cdt.h:102
dtlink_s_
Definition
cdt.h:51
dtlink_s_::right
Dtlink_t * right
Definition
cdt.h:51
s
Definition
grammar.c:93
lib
cdt
dtflatten.c
Generated by
1.9.8