00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _EGG_HASH_TABLE_H_
00023 #define _EGG_HASH_TABLE_H_
00024
00025 #define HASH_TABLE_STRINGS 1
00026 #define HASH_TABLE_INTS 2
00027 #define HASH_TABLE_MIXED 4
00028 #define HASH_TABLE_NORESIZE 8
00029 #define HASH_TABLE_FREE_KEY 16
00030
00031
00032
00033 #define HASH_TABLE_RESIZE_BOUNDARY 150
00034
00035
00036 typedef unsigned int (*hash_table_hash_alg)(const void *key);
00037
00038
00039 typedef int (*hash_table_cmp_alg)(const void *left, const void *right);
00040
00041 typedef int (*hash_table_node_func)(const void *key, void *data, void *param);
00042
00043 typedef struct hash_table_entry_b {
00044 struct hash_table_entry_b *next;
00045 void *key;
00046 void *data;
00047 unsigned int hash;
00048 } hash_table_entry_t;
00049
00050 typedef struct {
00051 int len;
00052 hash_table_entry_t *head;
00053 } hash_table_row_t;
00054
00055 typedef struct hash_table_b {
00056 int flags;
00057 int max_rows;
00058 int cells_in_use;
00059 hash_table_hash_alg hash;
00060 hash_table_cmp_alg cmp;
00061 hash_table_row_t *rows;
00062 } hash_table_t;
00063
00064 hash_table_t *hash_table_create(hash_table_hash_alg alg, hash_table_cmp_alg cmp, int nrows, int flags);
00065 int hash_table_delete(hash_table_t *ht);
00066 int hash_table_check_resize(hash_table_t *ht);
00067 int hash_table_resize(hash_table_t *ht, int nrows);
00068 int hash_table_insert(hash_table_t *ht, void *key, void *data);
00069 int hash_table_replace(hash_table_t *ht, const void *key, void *data);
00070 int hash_table_find(hash_table_t *ht, const void *key, void *dataptr);
00071 int hash_table_remove(hash_table_t *ht, const void *key, void *dataptr);
00072 int hash_table_walk(hash_table_t *ht, hash_table_node_func callback, void *param);
00073
00074 #endif