Graphviz
2.41.20171026.1811
Main Page
Data Structures
Files
File List
Globals
lib
cdt
dtsize.c
Go to the documentation of this file.
1
#include "
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(
reg
Dtlink_t
* e)
9
{
return
e ? treecount(e->left) + treecount(e->right) + 1 : 0;
10
}
11
12
int
dtsize
(
Dt_t
* dt)
13
{
14
reg
Dtlink_t
* t;
15
reg
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_LIST
|
DT_STACK
|
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
}
reg
#define reg
Definition:
dthdr.h:14
DT_QUEUE
#define DT_QUEUE
Definition:
cdt.h:131
_dtdata_s::size
int size
Definition:
cdt.h:73
DT_OSET
#define DT_OSET
Definition:
cdt.h:127
_dtlink_s
Definition:
cdt.h:44
dtsize
CDT_API int dtsize(Dt_t *)
Definition:
dtsize.c:12
DT_STACK
#define DT_STACK
Definition:
cdt.h:130
DT_OBAG
#define DT_OBAG
Definition:
cdt.h:128
DT_LIST
#define DT_LIST
Definition:
cdt.h:129
UNFLATTEN
#define UNFLATTEN(dt)
Definition:
dthdr.h:38
_dtdata_s::here
Dtlink_t * here
Definition:
cdt.h:67
dthdr.h
_dt_s
Definition:
cdt.h:99
_dt_s::data
Dtdata_t * data
Definition:
cdt.h:102
_dtdata_s::type
int type
Definition:
cdt.h:66
Generated by
1.8.5