xref: /PHP-5.4/ext/mbstring/oniguruma/st.h (revision e95f9a0e)
1 /* This is a public domain general purpose hash table package written by Peter Moore @ UCB. */
2 
3 /* @(#) st.h 5.1 89/12/14 */
4 
5 #ifndef ST_INCLUDED
6 
7 #define ST_INCLUDED
8 
9 typedef unsigned long st_data_t;
10 #define ST_DATA_T_DEFINED
11 
12 typedef struct st_table st_table;
13 
14 struct st_hash_type {
15     int (*compare)();
16     int (*hash)();
17 };
18 
19 struct st_table {
20     struct st_hash_type *type;
21     int num_bins;
22     int num_entries;
23     struct st_table_entry **bins;
24 };
25 
26 #define st_is_member(table,key) st_lookup(table,key,(st_data_t *)0)
27 
28 enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK};
29 
30 #ifndef _
31 # define _(args) args
32 #endif
33 #ifndef ANYARGS
34 # ifdef __cplusplus
35 #   define ANYARGS ...
36 # else
37 #   define ANYARGS
38 # endif
39 #endif
40 
41 st_table *st_init_table _((struct st_hash_type *));
42 st_table *st_init_table_with_size _((struct st_hash_type *, int));
43 st_table *st_init_numtable _((void));
44 st_table *st_init_numtable_with_size _((int));
45 st_table *st_init_strtable _((void));
46 st_table *st_init_strtable_with_size _((int));
47 int st_delete _((st_table *, st_data_t *, st_data_t *));
48 int st_delete_safe _((st_table *, st_data_t *, st_data_t *, st_data_t));
49 int st_insert _((st_table *, st_data_t, st_data_t));
50 int st_lookup _((st_table *, st_data_t, st_data_t *));
51 int st_foreach _((st_table *, int (*)(ANYARGS), st_data_t));
52 void st_add_direct _((st_table *, st_data_t, st_data_t));
53 void st_free_table _((st_table *));
54 void st_cleanup_safe _((st_table *, st_data_t));
55 st_table *st_copy _((st_table *));
56 
57 #define ST_NUMCMP	((int (*)()) 0)
58 #define ST_NUMHASH	((int (*)()) -2)
59 
60 #define st_numcmp	ST_NUMCMP
61 #define st_numhash	ST_NUMHASH
62 
63 #endif /* ST_INCLUDED */
64