emergency commit
[cl-cudd.git] / distr / st / doc / stExtDet.html
blob43cb6f46453ba38b0e3d99561d502e8f97d4693f
1 <html>
2 <head><title>The st package</title></head>
3 <body>
5 <h1>The st package</h1>
6 <h2>Symbol table package.</h2>
7 <h3></h3>
8 <hr>
9 <ul>
10 <li><a href="stExtAbs.html"><h3>External abstracts</h3></a>
11 <li><a href="stAllAbs.html"><h3>All abstracts</h3></a>
12 <li><a href="stExtDet.html#prototypes"><h3>External functions</h3></a>
13 <li><a href="stAllDet.html#prototypes"><h3>All functions</h3></a>
14 </ul>
16 <hr>
18 <a name="description">
19 The st library provides functions to create, maintain,
20 and query symbol tables.
21 </a>
23 <hr>
24 <!-- Function Prototypes and description -->
26 <dl>
27 <a name="prototypes"></a>
28 <dt><pre>
29 int <i></i>
30 <a name="st_add_direct"><b>st_add_direct</b></a>(
31 st_table * <b>table</b>, <i></i>
32 void * <b>key</b>, <i></i>
33 void * <b>value</b> <i></i>
35 </pre>
36 <dd> Place 'value' in 'table' under the key 'key'. This is done without checking if 'key' is in 'table' already. This should only be used if you are sure there is not already an entry for 'key', since it is undefined which entry you would later get from st_lookup or st_find_or_add. Returns 1 if successful; ST_OUT_OF_MEM otherwise.
37 <p>
39 <dd> <b>Side Effects</b> None
40 <p>
42 <dt><pre>
43 st_table * <i></i>
44 <a name="st_copy"><b>st_copy</b></a>(
45 st_table * <b>old_table</b> <i></i>
47 </pre>
48 <dd> Return a copy of old_table and all its members. (st_table *) 0 is returned if there was insufficient memory to do the copy.
49 <p>
51 <dd> <b>Side Effects</b> None
52 <p>
54 <dt><pre>
55 <i></i>
56 <a name="st_count"><b>st_count</b></a>(
57 <b>table</b> <i></i>
59 </pre>
60 <dd> Returns the number of entries in the table `table'.
61 <p>
63 <dd> <b>Side Effects</b> None
64 <p>
66 <dt><pre>
67 int <i></i>
68 <a name="st_delete_int"><b>st_delete_int</b></a>(
69 st_table * <b>table</b>, <i></i>
70 void * <b>keyp</b>, <i></i>
71 int * <b>value</b> <i></i>
73 </pre>
74 <dd> Delete the entry with the key pointed to by `keyp'. `value' must be a pointer to an integer. If the entry is found, 1 is returned, the variable pointed by `keyp' is set to the actual key and the variable pointed by `value' is set to the corresponding entry. (This allows the freeing of the associated storage.) If the entry is not found, then 0 is returned and nothing is changed.
75 <p>
77 <dd> <b>Side Effects</b> None
78 <p>
80 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_delete">st_delete</a>
81 </code>
83 <dt><pre>
84 int <i></i>
85 <a name="st_delete"><b>st_delete</b></a>(
86 st_table * <b>table</b>, <i></i>
87 void * <b>keyp</b>, <i></i>
88 void * <b>value</b> <i></i>
90 </pre>
91 <dd> Delete the entry with the key pointed to by `keyp'. If the entry is found, 1 is returned, the variable pointed by `keyp' is set to the actual key and the variable pointed by `value' is set to the corresponding entry. (This allows the freeing of the associated storage.) If the entry is not found, then 0 is returned and nothing is changed.
92 <p>
94 <dd> <b>Side Effects</b> None
95 <p>
97 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_delete_int">st_delete_int</a>
98 </code>
100 <dt><pre>
101 int <i></i>
102 <a name="st_find_or_add"><b>st_find_or_add</b></a>(
103 st_table * <b>table</b>, <i></i>
104 void * <b>key</b>, <i></i>
105 void * <b>slot</b> <i></i>
107 </pre>
108 <dd> Lookup `key' in `table'. If not found, create an entry. In either case set slot to point to the field in the entry where the value is stored. The value associated with `key' may then be changed by accessing directly through slot. Returns 1 if an entry already existed, 0 if it did not exist and creation was successful; ST_OUT_OF_MEM otherwise. As an example: <pre> char **slot; </pre> <pre> char *key; </pre> <pre> char *value = (char *) item_ptr <-- ptr to a malloc'd structure </pre> <pre> if (st_find_or_add(table, key, &slot) == 1) { </pre> <pre> FREE(*slot); <-- free the old value of the record </pre> <pre> } </pre> <pre> *slot = value; <-- attach the new value to the record </pre> This replaces the equivelent code: <pre> if (st_lookup(table, key, &ovalue) == 1) { </pre> <pre> FREE(ovalue); </pre> <pre> } </pre> <pre> st_insert(table, key, value); </pre>
111 <dd> <b>Side Effects</b> None
114 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_find">st_find</a>
115 </code>
117 <dt><pre>
118 int <i></i>
119 <a name="st_find"><b>st_find</b></a>(
120 st_table * <b>table</b>, <i></i>
121 void * <b>key</b>, <i></i>
122 void * <b>slot</b> <i></i>
124 </pre>
125 <dd> Like st_find_or_add, but does not create an entry if one is not found.
128 <dd> <b>Side Effects</b> None
131 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_find_or_add">st_find_or_add</a>
132 </code>
134 <dt><pre>
135 <i></i>
136 <a name="st_foreach_item_int"><b>st_foreach_item_int</b></a>(
137 <b>table</b>, <i></i>
138 <b>gen</b>, <i></i>
139 <b>key</b>, <i></i>
140 <b>value</b> <i></i>
142 </pre>
143 <dd> An iteration macro which loops over all the entries in `table', setting `key' to point to the key and `value' to the associated value (if it is not nil). `value' is assumed to be a pointer to an integer. `gen' is a generator variable used internally. Sample usage: <pre> char *key; </pre> <pre> int value; </pre> <pre> st_generator *gen; </pre> <pre> st_foreach_item_int(table, gen, &key, &value) { </pre> <pre> process_item(value); </pre> <pre> } </pre>
146 <dd> <b>Side Effects</b> None
149 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_foreach_item">st_foreach_item</a>
150 <a href="stAllDet.html#st_foreach">st_foreach</a>
151 </code>
153 <dt><pre>
154 <i></i>
155 <a name="st_foreach_item"><b>st_foreach_item</b></a>(
156 <b>table</b>, <i></i>
157 <b>gen</b>, <i></i>
158 <b>key</b>, <i></i>
159 <b>value</b> <i></i>
161 </pre>
162 <dd> An iteration macro which loops over all the entries in `table', setting `key' to point to the key and `value' to the associated value (if it is not nil). `gen' is a generator variable used internally. Sample usage: <pre> char *key, *value; </pre> <pre> st_generator *gen; </pre> <pre> st_foreach_item(table, gen, &key, &value) { </pre> <pre> process_item(value); </pre> <pre> } </pre>
165 <dd> <b>Side Effects</b> None
168 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_foreach_item_int">st_foreach_item_int</a>
169 <a href="stAllDet.html#st_foreach">st_foreach</a>
170 </code>
172 <dt><pre>
173 int <i></i>
174 <a name="st_foreach"><b>st_foreach</b></a>(
175 st_table * <b>table</b>, <i></i>
176 ST_PFSR <b>func</b>, <i></i>
177 char * <b>arg</b> <i></i>
179 </pre>
180 <dd> For each (key, value) record in `table', st_foreach call func with the arguments <pre> (*func)(key, value, arg) </pre> If func returns ST_CONTINUE, st_foreach continues processing entries. If func returns ST_STOP, st_foreach stops processing and returns immediately. If func returns ST_DELETE, then the entry is deleted from the symbol table and st_foreach continues. In the case of ST_DELETE, it is func's responsibility to free the key and value, if necessary.<p> The routine returns 1 if all items in the table were generated and 0 if the generation sequence was aborted using ST_STOP. The order in which the records are visited will be seemingly random.
183 <dd> <b>Side Effects</b> None
186 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_foreach_item">st_foreach_item</a>
187 <a href="stAllDet.html#st_foreach_item_int">st_foreach_item_int</a>
188 </code>
190 <dt><pre>
191 void <i></i>
192 <a name="st_free_gen"><b>st_free_gen</b></a>(
193 st_generator * <b>gen</b> <i></i>
195 </pre>
196 <dd> After generating all items in a generation sequence, this routine must be called to reclaim the resources associated with `gen'.
199 <dd> <b>Side Effects</b> None
202 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_gen">st_init_gen</a>
203 </code>
205 <dt><pre>
206 void <i></i>
207 <a name="st_free_table"><b>st_free_table</b></a>(
208 st_table * <b>table</b> <i></i>
210 </pre>
211 <dd> Any internal storage associated with table is freed. It is the user's responsibility to free any storage associated with the pointers he placed in the table (by perhaps using st_foreach).
214 <dd> <b>Side Effects</b> None
217 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_table">st_init_table</a>
218 <a href="stAllDet.html#st_init_table_with_params">st_init_table_with_params</a>
219 </code>
221 <dt><pre>
222 int <i></i>
223 <a name="st_gen_int"><b>st_gen_int</b></a>(
224 st_generator * <b>gen</b>, <i></i>
225 void * <b>key_p</b>, <i></i>
226 int * <b>value_p</b> <i></i>
228 </pre>
229 <dd> Given a generator returned by st_init_gen(), this routine returns the next (key, value) pair in the generation sequence. `value_p' must be a pointer to an integer. The pointer `value_p' can be zero which means no value will be returned. When there are no more items in the generation sequence, the routine returns 0.
232 <dd> <b>Side Effects</b> None
235 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_gen">st_gen</a>
236 </code>
238 <dt><pre>
239 int <i></i>
240 <a name="st_gen"><b>st_gen</b></a>(
241 st_generator * <b>gen</b>, <i></i>
242 void * <b>key_p</b>, <i></i>
243 void * <b>value_p</b> <i></i>
245 </pre>
246 <dd> Given a generator returned by st_init_gen(), this routine returns the next (key, value) pair in the generation sequence. The pointer `value_p' can be zero which means no value will be returned. When there are no more items in the generation sequence, the routine returns 0. While using a generation sequence, deleting any (key, value) pair other than the one just generated may cause a fatal error when st_gen() is called later in the sequence and is therefore not recommended.
249 <dd> <b>Side Effects</b> None
252 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_gen_int">st_gen_int</a>
253 </code>
255 <dt><pre>
256 st_generator * <i></i>
257 <a name="st_init_gen"><b>st_init_gen</b></a>(
258 st_table * <b>table</b> <i></i>
260 </pre>
261 <dd> Returns a generator handle which when used with st_gen() will progressively return each (key, value) record in `table'.
264 <dd> <b>Side Effects</b> None
267 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_free_gen">st_free_gen</a>
268 </code>
270 <dt><pre>
271 st_table * <i></i>
272 <a name="st_init_table_with_params"><b>st_init_table_with_params</b></a>(
273 ST_PFICPCP <b>compare</b>, <i></i>
274 ST_PFICPI <b>hash</b>, <i></i>
275 int <b>size</b>, <i></i>
276 int <b>density</b>, <i></i>
277 double <b>grow_factor</b>, <i></i>
278 int <b>reorder_flag</b> <i></i>
280 </pre>
281 <dd> The full blown table initializer. compare and hash are the same as in st_init_table. density is the largest the average number of entries per hash bin there should be before the table is grown. grow_factor is the factor the table is grown by when it becomes too full. size is the initial number of bins to be allocated for the hash table. If reorder_flag is non-zero, then every time an entry is found, it is moved to the top of the chain.<p> st_init_table(compare, hash) is equivelent to <pre> st_init_table_with_params(compare, hash, ST_DEFAULT_INIT_TABLE_SIZE, ST_DEFAULT_MAX_DENSITY, ST_DEFAULT_GROW_FACTOR, ST_DEFAULT_REORDER_FLAG); </pre>
284 <dd> <b>Side Effects</b> None
287 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_table">st_init_table</a>
288 <a href="stAllDet.html#st_free_table">st_free_table</a>
289 </code>
291 <dt><pre>
292 st_table * <i></i>
293 <a name="st_init_table"><b>st_init_table</b></a>(
294 ST_PFICPCP <b>compare</b>, <i></i>
295 ST_PFICPI <b>hash</b> <i></i>
297 </pre>
298 <dd> Create and initialize a table with the comparison function compare_fn and hash function hash_fn. compare_fn is <pre> int compare_fn(const char *key1, const char *key2) </pre> It returns <,=,> 0 depending on whether key1 <,=,> key2 by some measure.<p> hash_fn is <pre> int hash_fn(char *key, int modulus) </pre> It returns a integer between 0 and modulus-1 such that if compare_fn(key1,key2) == 0 then hash_fn(key1) == hash_fn(key2).<p> There are five predefined hash and comparison functions in st. For keys as numbers: <pre> st_numhash(key, modulus) { return (unsigned int) key % modulus; } </pre> <pre> st_numcmp(x,y) { return (int) x - (int) y; } </pre> For keys as pointers: <pre> st_ptrhash(key, modulus) { return ((unsigned int) key/4) % modulus } </pre> <pre> st_ptrcmp(x,y) { return (int) x - (int) y; } </pre> For keys as strings: <pre> st_strhash(x,y) - a reasonable hashing function for strings </pre> <pre> strcmp(x,y) - the standard library function </pre> It is recommended to use these particular functions if they fit your needs, since st will recognize certain of them and run more quickly because of it.
301 <dd> <b>Side Effects</b> None
304 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_table_with_params">st_init_table_with_params</a>
305 <a href="stAllDet.html#st_free_table">st_free_table</a>
306 </code>
308 <dt><pre>
309 int <i></i>
310 <a name="st_insert"><b>st_insert</b></a>(
311 st_table * <b>table</b>, <i></i>
312 void * <b>key</b>, <i></i>
313 void * <b>value</b> <i></i>
315 </pre>
316 <dd> Insert value in table under the key 'key'. Returns 1 if there was an entry already under the key; 0 if there was no entry under the key and insertion was successful; ST_OUT_OF_MEM otherwise. In either of the first two cases the new value is added.
319 <dd> <b>Side Effects</b> None
322 <dt><pre>
323 <i></i>
324 <a name="st_is_member"><b>st_is_member</b></a>(
325 <b>table</b>, <i></i>
326 <b>key</b> <i></i>
328 </pre>
329 <dd> Returns 1 if there is an entry under `key' in `table', 0 otherwise.
332 <dd> <b>Side Effects</b> None
335 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_lookup">st_lookup</a>
336 </code>
338 <dt><pre>
339 int <i></i>
340 <a name="st_lookup_int"><b>st_lookup_int</b></a>(
341 st_table * <b>table</b>, <i></i>
342 void * <b>key</b>, <i></i>
343 int * <b>value</b> <i></i>
345 </pre>
346 <dd> Lookup up `key' in `table'. If an entry is found, 1 is returned and if `value' is not nil, the variable it points to is set to the associated integer value. If an entry is not found, 0 is return and the variable pointed by `value' is unchanged.
349 <dd> <b>Side Effects</b> None
352 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_lookup">st_lookup</a>
353 </code>
355 <dt><pre>
356 int <i></i>
357 <a name="st_lookup"><b>st_lookup</b></a>(
358 st_table * <b>table</b>, <i></i>
359 void * <b>key</b>, <i></i>
360 void * <b>value</b> <i></i>
362 </pre>
363 <dd> Lookup up `key' in `table'. If an entry is found, 1 is returned and if `value' is not nil, the variable it points to is set to the associated value. If an entry is not found, 0 is returned and the variable pointed by value is unchanged.
366 <dd> <b>Side Effects</b> None
369 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_lookup_int">st_lookup_int</a>
370 </code>
372 <dt><pre>
373 int <i></i>
374 <a name="st_numcmp"><b>st_numcmp</b></a>(
375 const char * <b>x</b>, <i></i>
376 const char * <b>y</b> <i></i>
378 </pre>
379 <dd> integer number comparison function.
382 <dd> <b>Side Effects</b> None
385 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_table">st_init_table</a>
386 <a href="stAllDet.html#st_numhash">st_numhash</a>
387 </code>
389 <dt><pre>
390 int <i></i>
391 <a name="st_numhash"><b>st_numhash</b></a>(
392 char * <b>x</b>, <i></i>
393 int <b>size</b> <i></i>
395 </pre>
396 <dd> Integer number hash function.
399 <dd> <b>Side Effects</b> None
402 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_table">st_init_table</a>
403 <a href="stAllDet.html#st_numcmp">st_numcmp</a>
404 </code>
406 <dt><pre>
407 int <i></i>
408 <a name="st_ptrcmp"><b>st_ptrcmp</b></a>(
409 const char * <b>x</b>, <i></i>
410 const char * <b>y</b> <i></i>
412 </pre>
413 <dd> Pointer comparison function.
416 <dd> <b>Side Effects</b> None
419 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_table">st_init_table</a>
420 <a href="stAllDet.html#st_ptrhash">st_ptrhash</a>
421 </code>
423 <dt><pre>
424 int <i></i>
425 <a name="st_ptrhash"><b>st_ptrhash</b></a>(
426 char * <b>x</b>, <i></i>
427 int <b>size</b> <i></i>
429 </pre>
430 <dd> Pointer hash function.
433 <dd> <b>Side Effects</b> None
436 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_table">st_init_table</a>
437 <a href="stAllDet.html#st_ptrcmp">st_ptrcmp</a>
438 </code>
440 <dt><pre>
441 int <i></i>
442 <a name="st_strhash"><b>st_strhash</b></a>(
443 char * <b>string</b>, <i></i>
444 int <b>modulus</b> <i></i>
446 </pre>
447 <dd> String hash function.
450 <dd> <b>Side Effects</b> None
453 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_table">st_init_table</a>
454 </code>
457 </dl>
459 <hr>
461 Generated automatically by <code>extdoc</code> on 20040102
463 </body></html>