2 ** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
5 #ifndef _KERNEL_KHASH_H
6 #define _KERNEL_KHASH_H
13 void *hash_init(unsigned int table_size
, int next_ptr_offset
,
14 int compare_func(void *a
, const void *key
),
15 unsigned int hash_func(void *a
, const void *key
, unsigned int range
));
16 int hash_uninit(void *_hash_table
);
17 int hash_insert(void *_hash_table
, void *_elem
);
18 int hash_remove(void *_hash_table
, void *_elem
);
19 void *hash_find(void *_hash_table
, void *e
);
20 void *hash_lookup(void *_hash_table
, const void *key
);
21 struct hash_iterator
*hash_open(void *_hash_table
, struct hash_iterator
*i
);
22 void hash_close(void *_hash_table
, struct hash_iterator
*i
, bool free_iterator
);
23 void *hash_next(void *_hash_table
, struct hash_iterator
*i
);
24 void hash_rewind(void *_hash_table
, struct hash_iterator
*i
);
25 void hash_dump(void *_hash_table
);
27 /* function ptrs must look like this:
28 // hash function should calculate hash on either e or key,
29 // depending on which one is not NULL
30 unsigned int hash_func(void *e, const void *key, unsigned int range);
31 // compare function should compare the element with
32 // the key, returning 0 if equal, other if not
33 // NOTE: compare func can be null, in which case the hash
34 // code will compare the key pointer with the target
35 int compare_func(void *e, const void *key);
38 unsigned int hash_hash_str( const char *str
);