Back to index

php5  5.3.10
st.h
Go to the documentation of this file.
00001 /* This is a public domain general purpose hash table package written by Peter Moore @ UCB. */
00002 
00003 /* @(#) st.h 5.1 89/12/14 */
00004 
00005 #ifndef ST_INCLUDED
00006 
00007 #define ST_INCLUDED
00008 
00009 typedef unsigned long st_data_t;
00010 #define ST_DATA_T_DEFINED
00011 
00012 typedef struct st_table st_table;
00013 
00014 struct st_hash_type {
00015     int (*compare)();
00016     int (*hash)();
00017 };
00018 
00019 struct st_table {
00020     struct st_hash_type *type;
00021     int num_bins;
00022     int num_entries;
00023     struct st_table_entry **bins;
00024 };
00025 
00026 #define st_is_member(table,key) st_lookup(table,key,(st_data_t *)0)
00027 
00028 enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK};
00029 
00030 #ifndef _
00031 # define _(args) args
00032 #endif
00033 #ifndef ANYARGS
00034 # ifdef __cplusplus
00035 #   define ANYARGS ...
00036 # else
00037 #   define ANYARGS
00038 # endif
00039 #endif
00040 
00041 st_table *st_init_table _((struct st_hash_type *));
00042 st_table *st_init_table_with_size _((struct st_hash_type *, int));
00043 st_table *st_init_numtable _((void));
00044 st_table *st_init_numtable_with_size _((int));
00045 st_table *st_init_strtable _((void));
00046 st_table *st_init_strtable_with_size _((int));
00047 int st_delete _((st_table *, st_data_t *, st_data_t *));
00048 int st_delete_safe _((st_table *, st_data_t *, st_data_t *, st_data_t));
00049 int st_insert _((st_table *, st_data_t, st_data_t));
00050 int st_lookup _((st_table *, st_data_t, st_data_t *));
00051 int st_foreach _((st_table *, int (*)(ANYARGS), st_data_t));
00052 void st_add_direct _((st_table *, st_data_t, st_data_t));
00053 void st_free_table _((st_table *));
00054 void st_cleanup_safe _((st_table *, st_data_t));
00055 st_table *st_copy _((st_table *));
00056 
00057 #define ST_NUMCMP    ((int (*)()) 0)
00058 #define ST_NUMHASH   ((int (*)()) -2)
00059 
00060 #define st_numcmp    ST_NUMCMP
00061 #define st_numhash   ST_NUMHASH
00062 
00063 #endif /* ST_INCLUDED */