Graphviz 14.1.3~dev.20260124.0732
Loading...
Searching...
No Matches
dtflatten.c
Go to the documentation of this file.
1#include "config.h"
2
3#include <cdt/dthdr.h>
4#include <stddef.h>
5
6/* Flatten a dictionary into a linked list.
7** This may be used when many traversals are likely.
8**
9** Written by Kiem-Phong Vo (5/25/96).
10*/
11
13{
14 Dtlink_t *t, *r, *list, *last, **s, **ends;
15
16 /* already flattened */
17 if (dt->data.type & DT_FLATTEN )
18 return dt->data.here;
19
20 list = last = NULL;
21 if (dt->data.type & DT_SET)
22 { for (ends = (s = dt->data.htab) + dt->data.ntab; s < ends; ++s)
23 { if((t = *s) )
24 { if(last)
25 last->right = t;
26 else list = last = t;
27 while(last->right)
28 last = last->right;
29 *s = last;
30 }
31 }
32 }
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:31
#define DT_SET
Definition cdt.h:119
Dtlink_t * dtflatten(Dt_t *dt)
Definition dtflatten.c:12
#define DT_FLATTEN
Definition dthdr.h:18
#define RROTATE(x, y)
Definition dthdr.h:35
node NULL
Definition grammar.y:181
Dtlink_t * here
Definition cdt.h:73
int type
Definition cdt.h:72
int ntab
Definition cdt.h:78
Definition cdt.h:98
Dtdata_t data
sharable data
Definition cdt.h:101
Definition grammar.c:90