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
8
static
int
treecount
(
Dtlink_t
* e)
9
{
return
e ?
treecount
(e->left) +
treecount
(e->
right
) + 1 : 0;
10
}
11
12
int
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
}
DT_OBAG
#define DT_OBAG
Definition
cdt.h:126
DT_OSET
#define DT_OSET
Definition
cdt.h:125
DT_QUEUE
#define DT_QUEUE
Definition
cdt.h:127
dthdr.h
UNFLATTEN
#define UNFLATTEN(dt)
Definition
dthdr.h:27
dtsize
int dtsize(Dt_t *dt)
Definition
dtsize.c:12
treecount
static int treecount(Dtlink_t *e)
Definition
dtsize.c:8
_dt_s
Definition
cdt.h:104
_dt_s::data
Dtdata_t * data
Definition
cdt.h:106
_dtdata_s::here
Dtlink_t * here
Definition
cdt.h:77
_dtdata_s::type
int type
Definition
cdt.h:76
_dtdata_s::size
int size
Definition
cdt.h:83
_dtlink_s
Definition
cdt.h:55
_dtlink_s::right
Dtlink_t * right
Definition
cdt.h:55
lib
cdt
dtsize.c
Generated by
1.9.8