Go to the source code of this file.
|
| st__table * | st__init_table_with_params (st__compare_func_type compare, st__hash_func_type hash, int size, int density, double grow_factor, int reorder_flag) |
| |
| st__table * | st__init_table (st__compare_func_type, st__hash_func_type) |
| |
| void | st__free_table (st__table *) |
| |
| int | st__lookup (st__table *, const char *, char **) |
| |
| int | st__lookup_int (st__table *, char *, int *) |
| |
| int | st__insert (st__table *, const char *, char *) |
| |
| int | st__add_direct (st__table *, char *, char *) |
| |
| int | st__find_or_add (st__table *, char *, char ***) |
| |
| int | st__find (st__table *, char *, char ***) |
| |
| st__table * | st__copy (st__table *) |
| |
| int | st__delete (st__table *, const char **, char **) |
| |
| int | st__delete_int (st__table *, long *, char **) |
| |
| int | st__foreach (st__table *, st__PFSR, char *) |
| |
| int | st__strhash (const char *, int) |
| |
| int | st__numhash (const char *, int) |
| |
| int | st__ptrhash (const char *, int) |
| |
| int | st__numcmp (const char *, const char *) |
| |
| int | st__ptrcmp (const char *, const char *) |
| |
| st__generator * | st__init_gen (st__table *) |
| |
| int | st__gen (st__generator *, const char **, char **) |
| |
| int | st__gen_int (st__generator *, const char **, long *) |
| |
| void | st__free_gen (st__generator *) |
| |
◆ ARGS
Value:
Definition at line 37 of file st.h.
◆ EXTERN
Definition at line 32 of file st.h.
◆ st__count
| #define st__count |
( |
| table | ) |
|
Value:
Definition at line 71 of file st.h.
◆ st__DEFAULT_GROW_FACTOR
| #define st__DEFAULT_GROW_FACTOR 2.0 |
Definition at line 104 of file st.h.
◆ st__DEFAULT_INIT_TABLE_SIZE
| #define st__DEFAULT_INIT_TABLE_SIZE 11 |
Definition at line 103 of file st.h.
◆ st__DEFAULT_MAX_DENSITY
| #define st__DEFAULT_MAX_DENSITY 5 |
Definition at line 102 of file st.h.
◆ st__DEFAULT_REORDER_FLAG
| #define st__DEFAULT_REORDER_FLAG 0 |
Definition at line 105 of file st.h.
◆ st__foreach_item
| #define st__foreach_item |
( |
| table, |
|
|
| gen, |
|
|
| key, |
|
|
| value ) |
Value:
ABC_NAMESPACE_IMPL_START typedef signed char value
int st__gen(st__generator *gen, const char **key_p, char **value_p)
void st__free_gen(st__generator *gen)
st__generator * st__init_gen(st__table *table)
Definition at line 107 of file st.h.
107#define st__foreach_item(table, gen, key, value) \
108 for(gen= st__init_gen(table); st__gen(gen,key,value) || ( st__free_gen(gen),0);)
◆ st__foreach_item_int
| #define st__foreach_item_int |
( |
| table, |
|
|
| gen, |
|
|
| key, |
|
|
| value ) |
Value:
int st__gen_int(st__generator *gen, const char **key_p, long *value_p)
Definition at line 110 of file st.h.
110#define st__foreach_item_int(table, gen, key, value) \
111 for(gen= st__init_gen(table); st__gen_int(gen,key,value) || ( st__free_gen(gen),0);)
◆ st__INCLUDED
Definition at line 16 of file st.h.
◆ st__is_member
| #define st__is_member |
( |
| table, |
|
|
| key ) |
Value:
int st__lookup(st__table *table, const char *key, char **value)
Definition at line 70 of file st.h.
◆ st__OUT_OF_MEM
| #define st__OUT_OF_MEM -10000 |
Definition at line 113 of file st.h.
◆ st__compare_func_type
| typedef int(* st__compare_func_type) (const char *, const char *) |
Definition at line 41 of file st.h.
◆ st__generator
| typedef struct st__generator st__generator |
Definition at line 63 of file st.h.
◆ st__hash_func_type
| typedef int(* st__hash_func_type) (const char *, int) |
Definition at line 42 of file st.h.
◆ st__PFI
| typedef int(* st__PFI) () |
Definition at line 76 of file st.h.
◆ st__PFSR
| typedef enum st__retval(* st__PFSR) (char *, char *, char *) |
Definition at line 63 of file st.h.
◆ st__table
| typedef struct st__table st__table |
Definition at line 51 of file st.h.
◆ st__table_entry
| typedef struct st__table_entry st__table_entry |
Definition at line 44 of file st.h.
◆ st__retval
| Enumerator |
|---|
| st__CONTINUE | |
| st__STOP | |
| st__DELETE | |
Definition at line 73 of file st.h.
◆ st__add_direct()
| int st__add_direct |
( |
st__table * | table, |
|
|
char * | key, |
|
|
char * | value ) |
|
extern |
Definition at line 205 of file st.c.
206{
207 int hash_val;
209
211 if (table->num_entries / table->num_bins >= table->max_density) {
214 }
215 }
218 if (newEntry == NULL) {
220 }
223 newEntry->
next = table->bins[hash_val];
224 table->bins[hash_val] = newEntry;
225 table->num_entries++;
226 return 1;
227}
#define ABC_ALLOC(type, num)
#define do_hash(key, table)
◆ st__copy()
Definition at line 330 of file st.c.
331{
334 int i, j, num_bins = old_table->
num_bins;
335
337 if (newEntry_table == NULL) {
338 return NULL;
339 }
340
341 *newEntry_table = *old_table;
343 if (newEntry_table->
bins == NULL) {
345 return NULL;
346 }
347 for(i = 0; i < num_bins ; i++) {
348 newEntry_table->
bins[i] = NULL;
349 ptr = old_table->
bins[i];
350 while (ptr != NULL) {
352 if (newEntry == NULL) {
353 for (j = 0; j <= i; j++) {
354 newEntryptr = newEntry_table->
bins[j];
355 while (newEntryptr != NULL) {
356 next = newEntryptr->
next;
358 newEntryptr = next;
359 }
360 }
363 return NULL;
364 }
365 *newEntry = *ptr;
366 newEntry->
next = newEntry_table->
bins[i];
367 newEntry_table->
bins[i] = newEntry;
369 }
370 }
371 return newEntry_table;
372}
◆ st__delete()
| int st__delete |
( |
st__table * | table, |
|
|
const char ** | keyp, |
|
|
char ** | value ) |
|
extern |
Definition at line 375 of file st.c.
376{
377 int hash_val;
378 const char *
key = *keyp;
380
382
384
385 if (ptr == NULL) {
386 return 0;
387 }
388
393 table->num_entries--;
394 return 1;
395}
#define FIND_ENTRY(table, hash_val, key, ptr, last)
◆ st__delete_int()
| int st__delete_int |
( |
st__table * | table, |
|
|
long * | keyp, |
|
|
char ** | value ) |
|
extern |
Definition at line 398 of file st.c.
399{
400 int hash_val;
401 char *
key = (
char *) *keyp;
403
405
407
408 if (ptr == NULL) {
409 return 0;
410 }
411
414 *keyp = (long) ptr->
key;
416 table->num_entries--;
417 return 1;
418}
◆ st__find()
| int st__find |
( |
st__table * | table, |
|
|
char * | key, |
|
|
char *** | slot ) |
|
extern |
Definition at line 264 of file st.c.
265{
266 int hash_val;
268
270
272
273 if (ptr == NULL) {
274 return 0;
275 } else {
276 if (slot != NULL) {
278 }
279 return 1;
280 }
281}
◆ st__find_or_add()
| int st__find_or_add |
( |
st__table * | table, |
|
|
char * | key, |
|
|
char *** | slot ) |
|
extern |
Definition at line 230 of file st.c.
231{
232 int hash_val;
234
236
238
239 if (ptr == NULL) {
240 if (table->num_entries / table->num_bins >= table->max_density) {
243 }
245 }
247 if (newEntry == NULL) {
249 }
251 newEntry->
record = (
char *) 0;
252 newEntry->
next = table->bins[hash_val];
253 table->bins[hash_val] = newEntry;
254 table->num_entries++;
255 if (slot != NULL) *slot = &newEntry->
record;
256 return 0;
257 } else {
258 if (slot != NULL) *slot = &ptr->
record;
259 return 1;
260 }
261}
◆ st__foreach()
◆ st__free_gen()
Definition at line 555 of file st.c.
◆ st__free_table()
Definition at line 81 of file st.c.
82{
84 int i;
85
86 for(i = 0; i < table->num_bins ; i++) {
87 ptr = table->bins[i];
88 while (ptr != NULL) {
91 ptr = next;
92 }
93 }
96}
◆ st__gen()
Definition at line 501 of file st.c.
502{
503 int i;
504
505 if (gen->
entry == NULL) {
506
507 for(i = gen->
index; i < gen->table->num_bins; i++) {
511 break;
512 }
513 }
514 if (gen->
entry == NULL) {
515 return 0;
516 }
517 }
519 if (value_p != 0) {
521 }
523 return 1;
524}
◆ st__gen_int()
Definition at line 528 of file st.c.
529{
530 int i;
531
532 if (gen->
entry == NULL) {
533
534 for(i = gen->
index; i < gen->table->num_bins; i++) {
538 break;
539 }
540 }
541 if (gen->
entry == NULL) {
542 return 0;
543 }
544 }
546 if (value_p != 0) {
548 }
550 return 1;
551}
◆ st__init_gen()
Definition at line 485 of file st.c.
486{
488
490 if (gen == NULL) {
491 return NULL;
492 }
496 return gen;
497}
◆ st__init_table()
Definition at line 72 of file st.c.
73{
78}
st__table * st__init_table_with_params(st__compare_func_type compare, st__hash_func_type hash, int size, int density, double grow_factor, int reorder_flag)
#define st__DEFAULT_GROW_FACTOR
#define st__DEFAULT_MAX_DENSITY
#define st__DEFAULT_REORDER_FLAG
#define st__DEFAULT_INIT_TABLE_SIZE
◆ st__init_table_with_params()
Definition at line 41 of file st.c.
42{
43 int i;
45
47 if (newTable == NULL) {
48 return NULL;
49 }
51 newTable->
hash = hash;
56 if (size <= 0) {
58 }
61 if (newTable->
bins == NULL) {
63 return NULL;
64 }
65 for(i = 0; i <
size; i++) {
66 newTable->
bins[i] = 0;
67 }
68 return newTable;
69}
st__compare_func_type compare
◆ st__insert()
Definition at line 171 of file st.c.
172{
173 int hash_val;
176
178
180
181 if (ptr == NULL) {
182 if (table->num_entries/table->num_bins >= table->max_density) {
185 }
187 }
189 if (newEntry == NULL) {
191 }
192 newEntry->
key = (
char *)
key;
194 newEntry->
next = table->bins[hash_val];
195 table->bins[hash_val] = newEntry;
196 table->num_entries++;
197 return 0;
198 } else {
200 return 1;
201 }
202}
◆ st__lookup()
Definition at line 114 of file st.c.
115{
116 int hash_val;
118
120
122
123 if (ptr == NULL) {
124 return 0;
125 } else {
128 }
129 return 1;
130 }
131}
◆ st__lookup_int()
| int st__lookup_int |
( |
st__table * | table, |
|
|
char * | key, |
|
|
int * | value ) |
|
extern |
Definition at line 134 of file st.c.
135{
136 int hash_val;
138
140
142
143 if (ptr == NULL) {
144 return 0;
145 } else {
148 }
149 return 1;
150 }
151}
◆ st__numcmp()
Definition at line 473 of file st.c.
◆ st__numhash()
| int st__numhash |
( |
const char * | x, |
|
|
int | size ) |
|
extern |
Definition at line 461 of file st.c.
462{
464}
#define st__NUMHASH(x, size)
◆ st__ptrcmp()
Definition at line 479 of file st.c.
◆ st__ptrhash()
| int st__ptrhash |
( |
const char * | x, |
|
|
int | size ) |
|
extern |
Definition at line 467 of file st.c.
468{
470}
#define st__PTRHASH(x, size)
◆ st__strhash()
| int st__strhash |
( |
const char * | string, |
|
|
int | modulus ) |
|
extern |
Definition at line 449 of file st.c.
450{
451 unsigned char * ustring = (unsigned char *)string;
452 unsigned c, val = 0;
454 while ((c = *ustring++) != '\0') {
455 val = val*997 + c;
456 }
457 return (int)(val%modulus);
458}