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
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}
static agxbuf last
last message
Definition agerror.c:29
#define DT_SET
Definition cdt.h:120
Dtlink_t * dtflatten(Dt_t *dt)
Definition dtflatten.c:10
#define DT_FLATTEN
Definition dthdr.h:18
#define RROTATE(x, y)
Definition dthdr.h:35
node NULL
Definition grammar.y:163
Dtlink_t * here
Definition cdt.h:73
int type
Definition cdt.h:72
int ntab
Definition cdt.h:78
Definition cdt.h:100
Dtdata_t data
sharable data
Definition cdt.h:102
Definition grammar.c:93