Graphviz 12.0.1~dev.20240715.2254
Loading...
Searching...
No Matches
dtsize.c
Go to the documentation of this file.
1#include <cdt/dthdr.h>
2
3/* Return the # of objects in the dictionary
4**
5** Written by Kiem-Phong Vo (5/25/96)
6*/
7
8static int treecount(Dtlink_t* e)
9{ return e ? treecount(e->left) + treecount(e->right) + 1 : 0;
10}
11
12int dtsize(Dt_t* dt)
13{
14 Dtlink_t* t;
15 int size;
16
17 UNFLATTEN(dt);
18
19 if(dt->data->size < 0) /* !(dt->data->type&(DT_SET|DT_BAG)) */
20 { if(dt->data->type&(DT_OSET|DT_OBAG))
21 dt->data->size = treecount(dt->data->here);
22 else if(dt->data->type&DT_QUEUE)
23 { for(size = 0, t = dt->data->head; t; t = t->right)
24 size += 1;
25 dt->data->size = size;
26 }
27 }
28
29 return dt->data->size;
30}
#define DT_OBAG
Definition cdt.h:126
#define DT_OSET
Definition cdt.h:125
#define DT_QUEUE
Definition cdt.h:127
#define UNFLATTEN(dt)
Definition dthdr.h:27
int dtsize(Dt_t *dt)
Definition dtsize.c:12
static int treecount(Dtlink_t *e)
Definition dtsize.c:8
Definition cdt.h:104
Dtdata_t * data
Definition cdt.h:106
Dtlink_t * here
Definition cdt.h:77
int type
Definition cdt.h:76
int size
Definition cdt.h:83