emergency commit
[cl-cudd.git] / distr / st / doc / stAllDet.html
blobe56d8834dfdf4d98fa3720b9e86974a4942023a2
1 <html>
2 <head><title>The st package (Internal) </title></head>
3 <body>
5 <h1>The st package (Internal) </h1>
6 <h2></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">
20 </a>
22 <hr>
23 <!-- Function Prototypes and description -->
25 <dl>
26 <a name="prototypes"></a>
27 <dt><pre>
28 int <i></i>
29 <a name="st_add_direct"><b>st_add_direct</b></a>(
30 st_table * <b>table</b>, <i></i>
31 void * <b>key</b>, <i></i>
32 void * <b>value</b> <i></i>
34 </pre>
35 <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.
36 <p>
38 <dd> <b>Side Effects</b> None
39 <p>
41 <dt><pre>
42 st_table * <i></i>
43 <a name="st_copy"><b>st_copy</b></a>(
44 st_table * <b>old_table</b> <i></i>
46 </pre>
47 <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.
48 <p>
50 <dd> <b>Side Effects</b> None
51 <p>
53 <dt><pre>
54 <i></i>
55 <a name="st_count"><b>st_count</b></a>(
56 <b>table</b> <i></i>
58 </pre>
59 <dd> Returns the number of entries in the table `table'.
60 <p>
62 <dd> <b>Side Effects</b> None
63 <p>
65 <dt><pre>
66 int <i></i>
67 <a name="st_delete_int"><b>st_delete_int</b></a>(
68 st_table * <b>table</b>, <i></i>
69 void * <b>keyp</b>, <i></i>
70 int * <b>value</b> <i></i>
72 </pre>
73 <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.
74 <p>
76 <dd> <b>Side Effects</b> None
77 <p>
79 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_delete">st_delete</a>
80 </code>
82 <dt><pre>
83 int <i></i>
84 <a name="st_delete"><b>st_delete</b></a>(
85 st_table * <b>table</b>, <i></i>
86 void * <b>keyp</b>, <i></i>
87 void * <b>value</b> <i></i>
89 </pre>
90 <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.
91 <p>
93 <dd> <b>Side Effects</b> None
94 <p>
96 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_delete_int">st_delete_int</a>
97 </code>
99 <dt><pre>
100 int <i></i>
101 <a name="st_find_or_add"><b>st_find_or_add</b></a>(
102 st_table * <b>table</b>, <i></i>
103 void * <b>key</b>, <i></i>
104 void * <b>slot</b> <i></i>
106 </pre>
107 <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>
110 <dd> <b>Side Effects</b> None
113 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_find">st_find</a>
114 </code>
116 <dt><pre>
117 int <i></i>
118 <a name="st_find"><b>st_find</b></a>(
119 st_table * <b>table</b>, <i></i>
120 void * <b>key</b>, <i></i>
121 void * <b>slot</b> <i></i>
123 </pre>
124 <dd> Like st_find_or_add, but does not create an entry if one is not found.
127 <dd> <b>Side Effects</b> None
130 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_find_or_add">st_find_or_add</a>
131 </code>
133 <dt><pre>
134 <i></i>
135 <a name="st_foreach_item_int"><b>st_foreach_item_int</b></a>(
136 <b>table</b>, <i></i>
137 <b>gen</b>, <i></i>
138 <b>key</b>, <i></i>
139 <b>value</b> <i></i>
141 </pre>
142 <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>
145 <dd> <b>Side Effects</b> None
148 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_foreach_item">st_foreach_item</a>
149 <a href="stAllDet.html#st_foreach">st_foreach</a>
150 </code>
152 <dt><pre>
153 <i></i>
154 <a name="st_foreach_item"><b>st_foreach_item</b></a>(
155 <b>table</b>, <i></i>
156 <b>gen</b>, <i></i>
157 <b>key</b>, <i></i>
158 <b>value</b> <i></i>
160 </pre>
161 <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>
164 <dd> <b>Side Effects</b> None
167 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_foreach_item_int">st_foreach_item_int</a>
168 <a href="stAllDet.html#st_foreach">st_foreach</a>
169 </code>
171 <dt><pre>
172 int <i></i>
173 <a name="st_foreach"><b>st_foreach</b></a>(
174 st_table * <b>table</b>, <i></i>
175 ST_PFSR <b>func</b>, <i></i>
176 char * <b>arg</b> <i></i>
178 </pre>
179 <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.
182 <dd> <b>Side Effects</b> None
185 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_foreach_item">st_foreach_item</a>
186 <a href="stAllDet.html#st_foreach_item_int">st_foreach_item_int</a>
187 </code>
189 <dt><pre>
190 void <i></i>
191 <a name="st_free_gen"><b>st_free_gen</b></a>(
192 st_generator * <b>gen</b> <i></i>
194 </pre>
195 <dd> After generating all items in a generation sequence, this routine must be called to reclaim the resources associated with `gen'.
198 <dd> <b>Side Effects</b> None
201 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_gen">st_init_gen</a>
202 </code>
204 <dt><pre>
205 void <i></i>
206 <a name="st_free_table"><b>st_free_table</b></a>(
207 st_table * <b>table</b> <i></i>
209 </pre>
210 <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).
213 <dd> <b>Side Effects</b> None
216 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_table">st_init_table</a>
217 <a href="stAllDet.html#st_init_table_with_params">st_init_table_with_params</a>
218 </code>
220 <dt><pre>
221 int <i></i>
222 <a name="st_gen_int"><b>st_gen_int</b></a>(
223 st_generator * <b>gen</b>, <i></i>
224 void * <b>key_p</b>, <i></i>
225 int * <b>value_p</b> <i></i>
227 </pre>
228 <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.
231 <dd> <b>Side Effects</b> None
234 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_gen">st_gen</a>
235 </code>
237 <dt><pre>
238 int <i></i>
239 <a name="st_gen"><b>st_gen</b></a>(
240 st_generator * <b>gen</b>, <i></i>
241 void * <b>key_p</b>, <i></i>
242 void * <b>value_p</b> <i></i>
244 </pre>
245 <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.
248 <dd> <b>Side Effects</b> None
251 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_gen_int">st_gen_int</a>
252 </code>
254 <dt><pre>
255 st_generator * <i></i>
256 <a name="st_init_gen"><b>st_init_gen</b></a>(
257 st_table * <b>table</b> <i></i>
259 </pre>
260 <dd> Returns a generator handle which when used with st_gen() will progressively return each (key, value) record in `table'.
263 <dd> <b>Side Effects</b> None
266 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_free_gen">st_free_gen</a>
267 </code>
269 <dt><pre>
270 st_table * <i></i>
271 <a name="st_init_table_with_params"><b>st_init_table_with_params</b></a>(
272 ST_PFICPCP <b>compare</b>, <i></i>
273 ST_PFICPI <b>hash</b>, <i></i>
274 int <b>size</b>, <i></i>
275 int <b>density</b>, <i></i>
276 double <b>grow_factor</b>, <i></i>
277 int <b>reorder_flag</b> <i></i>
279 </pre>
280 <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>
283 <dd> <b>Side Effects</b> None
286 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_table">st_init_table</a>
287 <a href="stAllDet.html#st_free_table">st_free_table</a>
288 </code>
290 <dt><pre>
291 st_table * <i></i>
292 <a name="st_init_table"><b>st_init_table</b></a>(
293 ST_PFICPCP <b>compare</b>, <i></i>
294 ST_PFICPI <b>hash</b> <i></i>
296 </pre>
297 <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.
300 <dd> <b>Side Effects</b> None
303 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_table_with_params">st_init_table_with_params</a>
304 <a href="stAllDet.html#st_free_table">st_free_table</a>
305 </code>
307 <dt><pre>
308 int <i></i>
309 <a name="st_insert"><b>st_insert</b></a>(
310 st_table * <b>table</b>, <i></i>
311 void * <b>key</b>, <i></i>
312 void * <b>value</b> <i></i>
314 </pre>
315 <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.
318 <dd> <b>Side Effects</b> None
321 <dt><pre>
322 <i></i>
323 <a name="st_is_member"><b>st_is_member</b></a>(
324 <b>table</b>, <i></i>
325 <b>key</b> <i></i>
327 </pre>
328 <dd> Returns 1 if there is an entry under `key' in `table', 0 otherwise.
331 <dd> <b>Side Effects</b> None
334 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_lookup">st_lookup</a>
335 </code>
337 <dt><pre>
338 int <i></i>
339 <a name="st_lookup_int"><b>st_lookup_int</b></a>(
340 st_table * <b>table</b>, <i></i>
341 void * <b>key</b>, <i></i>
342 int * <b>value</b> <i></i>
344 </pre>
345 <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.
348 <dd> <b>Side Effects</b> None
351 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_lookup">st_lookup</a>
352 </code>
354 <dt><pre>
355 int <i></i>
356 <a name="st_lookup"><b>st_lookup</b></a>(
357 st_table * <b>table</b>, <i></i>
358 void * <b>key</b>, <i></i>
359 void * <b>value</b> <i></i>
361 </pre>
362 <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.
365 <dd> <b>Side Effects</b> None
368 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_lookup_int">st_lookup_int</a>
369 </code>
371 <dt><pre>
372 int <i></i>
373 <a name="st_numcmp"><b>st_numcmp</b></a>(
374 const char * <b>x</b>, <i></i>
375 const char * <b>y</b> <i></i>
377 </pre>
378 <dd> integer number comparison function.
381 <dd> <b>Side Effects</b> None
384 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_table">st_init_table</a>
385 <a href="stAllDet.html#st_numhash">st_numhash</a>
386 </code>
388 <dt><pre>
389 int <i></i>
390 <a name="st_numhash"><b>st_numhash</b></a>(
391 char * <b>x</b>, <i></i>
392 int <b>size</b> <i></i>
394 </pre>
395 <dd> Integer number hash function.
398 <dd> <b>Side Effects</b> None
401 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_table">st_init_table</a>
402 <a href="stAllDet.html#st_numcmp">st_numcmp</a>
403 </code>
405 <dt><pre>
406 int <i></i>
407 <a name="st_ptrcmp"><b>st_ptrcmp</b></a>(
408 const char * <b>x</b>, <i></i>
409 const char * <b>y</b> <i></i>
411 </pre>
412 <dd> Pointer comparison function.
415 <dd> <b>Side Effects</b> None
418 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_table">st_init_table</a>
419 <a href="stAllDet.html#st_ptrhash">st_ptrhash</a>
420 </code>
422 <dt><pre>
423 int <i></i>
424 <a name="st_ptrhash"><b>st_ptrhash</b></a>(
425 char * <b>x</b>, <i></i>
426 int <b>size</b> <i></i>
428 </pre>
429 <dd> Pointer hash function.
432 <dd> <b>Side Effects</b> None
435 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_table">st_init_table</a>
436 <a href="stAllDet.html#st_ptrcmp">st_ptrcmp</a>
437 </code>
439 <dt><pre>
440 int <i></i>
441 <a name="st_strhash"><b>st_strhash</b></a>(
442 char * <b>string</b>, <i></i>
443 int <b>modulus</b> <i></i>
445 </pre>
446 <dd> String hash function.
449 <dd> <b>Side Effects</b> None
452 <dd> <b>See Also</b> <code><a href="stAllDet.html#st_init_table">st_init_table</a>
453 </code>
456 </dl>
458 <hr>
460 Generated automatically by <code>extdoc</code> on 20040102
462 </body></html>