Graphviz
2.41.20171026.1811
Main Page
Data Structures
Files
File List
Globals
lib
cdt
dtflatten.c
Go to the documentation of this file.
1
#include "
dthdr.h
"
2
3
/* Flatten a dictionary into a linked list.
4
** This may be used when many traversals are likely.
5
**
6
** Written by Kiem-Phong Vo (5/25/96).
7
*/
8
9
Dtlink_t
*
dtflatten
(
Dt_t
* dt)
10
{
11
reg
Dtlink_t
*t, *r, *list, *last, **
s
, **ends;
12
13
/* already flattened */
14
if
(dt->
data
->
type
&
DT_FLATTEN
)
15
return
dt->
data
->
here
;
16
17
list = last =
NIL
(
Dtlink_t
*);
18
if
(dt->
data
->
type
&(
DT_SET
|
DT_BAG
))
19
{
for
(ends = (s = dt->
data
->htab) + dt->
data
->
ntab
; s < ends; ++s)
20
{
if
((t = *s) )
21
{
if
(last)
22
last->right = t;
23
else
list = last = t;
24
while
(last->right)
25
last = last->right;
26
*s = last;
27
}
28
}
29
}
30
else
if
(dt->
data
->
type
&(
DT_LIST
|
DT_STACK
|
DT_QUEUE
) )
31
list = dt->
data
->head;
32
else
if
((r = dt->
data
->
here
) )
/*if(dt->data->type&(DT_OSET|DT_OBAG))*/
33
{
while
((t = r->left) )
34
RROTATE
(r,t);
35
for
(list = last = r, r = r->right; r; last = r, r = r->right)
36
{
if
((t = r->left) )
37
{
do
RROTATE
(r,t);
38
while
((t = r->left) );
39
40
last->right = r;
41
}
42
}
43
}
44
45
dt->
data
->
here
= list;
46
dt->
data
->
type
|=
DT_FLATTEN
;
47
48
return
list;
49
}
dtflatten
CDT_API Dtlink_t * dtflatten(Dt_t *)
Definition:
dtflatten.c:9
reg
#define reg
Definition:
dthdr.h:14
DT_SET
#define DT_SET
Definition:
cdt.h:125
DT_BAG
#define DT_BAG
Definition:
cdt.h:126
DT_QUEUE
#define DT_QUEUE
Definition:
cdt.h:131
NIL
#define NIL(t)
Definition:
dthdr.h:13
_dtlink_s
Definition:
cdt.h:44
DT_STACK
#define DT_STACK
Definition:
cdt.h:130
s
Definition:
grammar.c:79
RROTATE
#define RROTATE(x, y)
Definition:
dthdr.h:47
DT_LIST
#define DT_LIST
Definition:
cdt.h:129
_dtdata_s::here
Dtlink_t * here
Definition:
cdt.h:67
dthdr.h
DT_FLATTEN
#define DT_FLATTEN
Definition:
dthdr.h:22
_dtdata_s::ntab
int ntab
Definition:
cdt.h:72
_dt_s
Definition:
cdt.h:99
_dt_s::data
Dtdata_t * data
Definition:
cdt.h:102
_dtdata_s::type
int type
Definition:
cdt.h:66
Generated by
1.8.5