Graphviz
12.0.1~dev.20240715.2254
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
(dt->
data
->
type
&
DT_QUEUE
)
32
list = dt->
data
->head;
33
else
if
((r = dt->
data
->
here
) )
/*if(dt->data->type&(DT_OSET|DT_OBAG))*/
34
{
while
((t = r->left) )
35
RROTATE
(r,t);
36
for
(list =
last
= r, r = r->
right
; r;
last
= r, r = r->
right
)
37
{
if
((t = r->left) )
38
{
do
RROTATE
(r,t);
39
while
((t = r->left) );
40
41
last
->right = r;
42
}
43
}
44
}
45
46
dt->
data
->
here
= list;
47
dt->
data
->
type
|=
DT_FLATTEN
;
48
49
return
list;
50
}
last
static agxbuf last
last message
Definition
agerror.c:29
DT_SET
#define DT_SET
Definition
cdt.h:124
DT_QUEUE
#define DT_QUEUE
Definition
cdt.h:127
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:36
NULL
node NULL
Definition
grammar.y:149
_dt_s
Definition
cdt.h:104
_dt_s::data
Dtdata_t * data
Definition
cdt.h:106
_dtdata_s::ntab
int ntab
Definition
cdt.h:82
_dtdata_s::here
Dtlink_t * here
Definition
cdt.h:77
_dtdata_s::type
int type
Definition
cdt.h:76
_dtlink_s
Definition
cdt.h:55
_dtlink_s::right
Dtlink_t * right
Definition
cdt.h:55
s
Definition
grammar.c:93
lib
cdt
dtflatten.c
Generated by
1.9.8