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
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}
static agxbuf last
last message
Definition agerror.c:29
#define DT_SET
Definition cdt.h:124
#define DT_QUEUE
Definition cdt.h:127
Dtlink_t * dtflatten(Dt_t *dt)
Definition dtflatten.c:10
#define DT_FLATTEN
Definition dthdr.h:18
#define RROTATE(x, y)
Definition dthdr.h:36
node NULL
Definition grammar.y:149
Definition cdt.h:104
Dtdata_t * data
Definition cdt.h:106
int ntab
Definition cdt.h:82
Dtlink_t * here
Definition cdt.h:77
int type
Definition cdt.h:76
Definition grammar.c:93