comparison toolboxes/graph_visualisation/include/graphviz/cdt.h @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 /* $Id: cdt.h,v 1.11 2009/07/24 21:10:19 arif Exp $ $Revision: 1.11 $ */
2 /* vim:set shiftwidth=4 ts=8: */
3
4 /**********************************************************
5 * This software is part of the graphviz package *
6 * http://www.graphviz.org/ *
7 * *
8 * Copyright (c) 1994-2004 AT&T Corp. *
9 * and is licensed under the *
10 * Common Public License, Version 1.0 *
11 * by AT&T Corp. *
12 * *
13 * Information and Software Systems Research *
14 * AT&T Research, Florham Park NJ *
15 **********************************************************/
16
17 #ifndef _CDT_H
18 #define _CDT_H 1
19
20 /* Public interface for the dictionary library
21 **
22 ** Written by Kiem-Phong Vo (05/25/96)
23 */
24
25 #define CDT_VERSION 19991101L
26
27 #define Void_t void
28 #define _ARG_(x) x
29 #ifndef NIL
30 #define NIL(type) ((type)0)
31 #endif
32
33 #include <string.h>
34
35 #if _PACKAGE_ast
36 # include <ast_std.h>
37 #elif _BLD_cdt
38 # include "ast_common.h"
39 #endif
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 typedef struct _dtlink_s Dtlink_t;
46 typedef struct _dthold_s Dthold_t;
47 typedef struct _dtdisc_s Dtdisc_t;
48 typedef struct _dtmethod_s Dtmethod_t;
49 typedef struct _dtdata_s Dtdata_t;
50 typedef struct _dt_s Dt_t;
51 typedef struct _dt_s Dict_t; /* for libdict compatibility */
52 typedef struct _dtstat_s Dtstat_t;
53 typedef Void_t *(*Dtsearch_f) _ARG_((Dt_t *, Void_t *, int));
54 typedef Void_t *(*Dtmake_f) _ARG_((Dt_t *, Void_t *, Dtdisc_t *));
55 typedef void (*Dtfree_f) _ARG_((Dt_t *, Void_t *, Dtdisc_t *));
56 typedef int (*Dtcompar_f)
57 _ARG_((Dt_t *, Void_t *, Void_t *, Dtdisc_t *));
58 typedef unsigned int (*Dthash_f) _ARG_((Dt_t *, Void_t *, Dtdisc_t *));
59 typedef Void_t *(*Dtmemory_f)
60 _ARG_((Dt_t *, Void_t *, size_t, Dtdisc_t *));
61 typedef int (*Dtevent_f) _ARG_((Dt_t *, int, Void_t *, Dtdisc_t *));
62
63 struct _dtlink_s {
64 Dtlink_t *right; /* right child */
65 union {
66 unsigned int _hash; /* hash value */
67 Dtlink_t *_left; /* left child */
68 } hl;
69 };
70
71 /* private structure to hold an object */
72 struct _dthold_s {
73 Dtlink_t hdr; /* header */
74 Void_t *obj; /* user object */
75 };
76
77 /* method to manipulate dictionary structure */
78 struct _dtmethod_s {
79 Dtsearch_f searchf; /* search function */
80 int type; /* type of operation */
81 };
82
83 /* stuff that may be in shared memory */
84 struct _dtdata_s {
85 int type; /* type of dictionary */
86 Dtlink_t *here; /* finger to last search element */
87 union {
88 Dtlink_t **_htab; /* hash table */
89 Dtlink_t *_head; /* linked list */
90 } hh;
91 int ntab; /* number of hash slots */
92 int size; /* number of objects */
93 int loop; /* number of nested loops */
94 };
95
96 /* structure to hold methods that manipulate an object */
97 struct _dtdisc_s {
98 int key; /* where the key begins in an object */
99 int size; /* key size and type */
100 int link; /* offset to Dtlink_t field */
101 Dtmake_f makef; /* object constructor */
102 Dtfree_f freef; /* object destructor */
103 Dtcompar_f comparf; /* to compare two objects */
104 Dthash_f hashf; /* to compute hash value of an object */
105 Dtmemory_f memoryf; /* to allocate/free memory */
106 Dtevent_f eventf; /* to process events */
107 };
108
109 /* the dictionary structure itself */
110 struct _dt_s {
111 Dtsearch_f searchf; /* search function */
112 Dtdisc_t *disc; /* method to manipulate objs */
113 Dtdata_t *data; /* sharable data */
114 Dtmemory_f memoryf; /* function to alloc/free memory */
115 Dtmethod_t *meth; /* dictionary method */
116 int type; /* type information */
117 int nview; /* number of parent view dictionaries */
118 Dt_t *view; /* next on viewpath */
119 Dt_t *walk; /* dictionary being walked */
120 };
121
122 /* structure to get status of a dictionary */
123 struct _dtstat_s {
124 int dt_meth; /* method type */
125 int dt_size; /* number of elements */
126 int dt_n; /* number of chains or levels */
127 int dt_max; /* max size of a chain or a level */
128 int *dt_count; /* counts of chains or levels by size */
129 };
130
131 /* supported storage methods */
132 #define DT_SET 0000001 /* set with unique elements */
133 #define DT_BAG 0000002 /* multiset */
134 #define DT_OSET 0000004 /* ordered set (self-adjusting tree) */
135 #define DT_OBAG 0000010 /* ordered multiset */
136 #define DT_LIST 0000020 /* linked list */
137 #define DT_STACK 0000040 /* stack */
138 #define DT_QUEUE 0000100 /* queue */
139 #define DT_METHODS 0000177 /* all currently supported methods */
140
141 /* asserts to dtdisc() */
142 #define DT_SAMECMP 0000001 /* compare methods equivalent */
143 #define DT_SAMEHASH 0000002 /* hash methods equivalent */
144
145 /* types of search */
146 #define DT_INSERT 0000001 /* insert object if not found */
147 #define DT_DELETE 0000002 /* delete object if found */
148 #define DT_SEARCH 0000004 /* look for an object */
149 #define DT_NEXT 0000010 /* look for next element */
150 #define DT_PREV 0000020 /* find previous element */
151 #define DT_RENEW 0000040 /* renewing an object */
152 #define DT_CLEAR 0000100 /* clearing all objects */
153 #define DT_FIRST 0000200 /* get first object */
154 #define DT_LAST 0000400 /* get last object */
155 #define DT_MATCH 0001000 /* find object matching key */
156 #define DT_VSEARCH 0002000 /* search using internal representation */
157 #define DT_ATTACH 0004000 /* attach an object to the dictionary */
158 #define DT_DETACH 0010000 /* attach an object to the dictionary */
159
160 /* events */
161 #define DT_OPEN 1 /* a dictionary is being opened */
162 #define DT_CLOSE 2 /* a dictionary is being closed */
163 #define DT_DISC 3 /* discipline is about to be changed */
164 #define DT_METH 4 /* method is about to be changed */
165
166
167 #if _BLD_cdt && defined(__EXPORT__)
168 #define extern __EXPORT__
169 #endif
170 #if !_BLD_cdt && defined(GVDLL)
171 #define extern __declspec(dllimport)
172 #endif
173 #if !_BLD_cdt && defined(__IMPORT__)
174 #define extern __IMPORT__
175 #endif
176 /*visual studio*/
177 #ifdef WIN32_DLL
178 #ifndef CDT_EXPORTS
179 #define extern __declspec(dllimport)
180 #else
181 #define extern __declspec(dllexport)
182 #endif
183 #endif
184 /*end visual studio*/
185
186
187 extern Dtmethod_t *Dtset;
188 extern Dtmethod_t *Dtbag;
189 extern Dtmethod_t *Dtoset;
190 extern Dtmethod_t *Dtobag;
191 extern Dtmethod_t *Dtlist;
192 extern Dtmethod_t *Dtstack;
193 extern Dtmethod_t *Dtqueue;
194
195 /* compatibility stuff; will go away */
196 #ifndef KPVDEL
197 extern Dtmethod_t *Dtorder;
198 extern Dtmethod_t *Dttree;
199 extern Dtmethod_t *Dthash;
200 extern Dtmethod_t _Dttree;
201 extern Dtmethod_t _Dthash;
202 extern Dtmethod_t _Dtlist;
203 extern Dtmethod_t _Dtqueue;
204 extern Dtmethod_t _Dtstack;
205 #endif
206
207 #undef extern
208 #if _BLD_cdt && defined(__EXPORT__)
209 #define extern __EXPORT__
210 #endif
211 #if !_BLD_cdt && defined(__IMPORT__) && defined(__EXPORT__)
212 #define extern __IMPORT__
213 #endif
214 extern Dt_t *dtopen _ARG_((Dtdisc_t *, Dtmethod_t *));
215 extern int dtclose _ARG_((Dt_t *));
216 extern Dt_t *dtview _ARG_((Dt_t *, Dt_t *));
217 extern Dtdisc_t *dtdisc _ARG_((Dt_t * dt, Dtdisc_t *, int));
218 extern Dtmethod_t *dtmethod _ARG_((Dt_t *, Dtmethod_t *));
219
220 extern Dtlink_t *dtflatten _ARG_((Dt_t *));
221 extern Dtlink_t *dtextract _ARG_((Dt_t *));
222 extern int dtrestore _ARG_((Dt_t *, Dtlink_t *));
223
224 extern int dtwalk
225 _ARG_((Dt_t *, int (*)(Dt_t *, Void_t *, Void_t *), Void_t *));
226
227 extern Void_t *dtrenew _ARG_((Dt_t *, Void_t *));
228
229 extern int dtsize _ARG_((Dt_t *));
230 extern int dtstat _ARG_((Dt_t *, Dtstat_t *, int));
231 extern unsigned int dtstrhash _ARG_((unsigned int, Void_t *, int));
232
233 #undef extern
234
235 #define _DT_(d) ((Dt_t*)(d))
236 #define dtvnext(d) (_DT_(d)->view)
237 #define dtvcount(d) (_DT_(d)->nview)
238 #define dtvhere(d) (_DT_(d)->walk)
239 #define dtlink(d,e) (((Dtlink_t*)(e))->right)
240 #define dtobj(d,e) ((_DT_(d)->disc->link < 0) ? (((Dthold_t*)(e))->obj) : \
241 (Void_t*)((char*)(e) - _DT_(d)->disc->link) )
242 #define dtfinger(d) (_DT_(d)->data->here ? dtobj((d),_DT_(d)->data->here) : \
243 (Void_t*)(0) )
244 #define dtfirst(d) (*(_DT_(d)->searchf))((d),(Void_t*)(0),DT_FIRST)
245 #define dtnext(d,o) (*(_DT_(d)->searchf))((d),(Void_t*)(o),DT_NEXT)
246 #define dtlast(d) (*(_DT_(d)->searchf))((d),(Void_t*)(0),DT_LAST)
247 #define dtprev(d,o) (*(_DT_(d)->searchf))((d),(Void_t*)(o),DT_PREV)
248 #define dtsearch(d,o) (*(_DT_(d)->searchf))((d),(Void_t*)(o),DT_SEARCH)
249 #define dtmatch(d,o) (*(_DT_(d)->searchf))((d),(Void_t*)(o),DT_MATCH)
250 #define dtinsert(d,o) (*(_DT_(d)->searchf))((d),(Void_t*)(o),DT_INSERT)
251 #define dtdelete(d,o) (*(_DT_(d)->searchf))((d),(Void_t*)(o),DT_DELETE)
252 #define dtattach(d,o) (*(_DT_(d)->searchf))((d),(Void_t*)(o),DT_ATTACH)
253 #define dtdetach(d,o) (*(_DT_(d)->searchf))((d),(Void_t*)(o),DT_DETACH)
254 #define dtclear(d) (*(_DT_(d)->searchf))((d),(Void_t*)(0),DT_CLEAR)
255 /* A linear congruential hash: h*17 + c + 97531 */
256 #define dtcharhash(h,c) ((((unsigned int)(h))<<4) + ((unsigned int)(h)) + \
257 ((unsigned char)(c)) + 97531 )
258 #ifdef __cplusplus
259 }
260 #endif
261 #endif /* _CDT_H */