Crossfire Server, Trunk  R20513
hashtable.h
Go to the documentation of this file.
1 /* Usually we will store only about 10 or so elements, however we may get
2  * cases of a fair bit more and we should handle those cases efficently.
3  * hashptr() assumes this value will fit in int.
4  */
5 #define PTR_ASSOC_TABLESIZE 251
6 
7 typedef struct _ptr_assoc {
8  struct _ptr_assoc **array;
10  struct _ptr_assoc *next;
11  void *key;
12  void *value;
13 } ptr_assoc;
14 
16 
18 extern void add_ptr_assoc(ptr_assoc **hash_table, void *key, void *value);
19 extern void *find_assoc_value(ptr_assoc **hash_table, void *key);
20 extern void free_ptr_assoc(ptr_assoc **hash_table, void *key);
ptr_assoc * ptr_assoc_table[PTR_ASSOC_TABLESIZE]
Definition: hashtable.h:15
struct _ptr_assoc * next
Definition: hashtable.h:10
void free_ptr_assoc(ptr_assoc **hash_table, void *key)
Remove the association with a given key.
Definition: hashtable.c:222
void * find_assoc_value(ptr_assoc **hash_table, void *key)
Find the value associated with a given key.
Definition: hashtable.c:205
void * key
Definition: hashtable.h:11
void * value
Definition: hashtable.h:12
static shared_string * hash_table[TABLESIZE]
Hash table to store our string.
Definition: shstr.c:50
void init_ptr_assoc_table(ptr_assoc **hash_table)
Initialises the hash table for a pointer association table.
Definition: hashtable.c:57
struct _ptr_assoc * previous
Definition: hashtable.h:9
struct _ptr_assoc ** array
Definition: hashtable.h:8
struct _ptr_assoc ptr_assoc
#define PTR_ASSOC_TABLESIZE
Definition: hashtable.h:5
void add_ptr_assoc(ptr_assoc **hash_table, void *key, void *value)
Adds a value to a hash table which one can lookup with key.
Definition: hashtable.c:109