4 #include "eina_types.h"
9 typedef struct _Eina_Hash Eina_Hash;
10 typedef unsigned int (*Eina_Key_Length)(const void *key);
11 #define EINA_KEY_LENGTH(Function) ((Eina_Key_Length)Function)
12 typedef int (*Eina_Key_Cmp)(const void *key1, int key1_length,
13 const void *key2, int key2_length);
14 #define EINA_KEY_CMP(Function) ((Eina_Key_Cmp)Function)
15 typedef int (*Eina_Key_Hash)(const void *key, int key_length);
16 #define EINA_KEY_HASH(Function) ((Eina_Key_Hash)Function)
18 EAPI int eina_hash_init(void);
19 EAPI int eina_hash_shutdown(void);
21 EAPI Eina_Hash * eina_hash_new(Eina_Key_Length key_length_cb,
22 Eina_Key_Cmp key_cmp_cb,
23 Eina_Key_Hash key_hash_cb);
24 EAPI Eina_Hash * eina_hash_string_djb2_new(void);
25 EAPI Eina_Hash * eina_hash_string_superfast_new(void);
27 EAPI Eina_Bool eina_hash_add(Eina_Hash *hash, const void *key, const void *data);
28 EAPI Eina_Bool eina_hash_direct_add(Eina_Hash *hash, const void *key, const void *data);
29 EAPI Eina_Bool eina_hash_del(Eina_Hash *hash, const void *key, const void *data);
30 EAPI void * eina_hash_find(const Eina_Hash *hash, const void *key);
31 EAPI void * eina_hash_modify(Eina_Hash *hash, const void *key, const void *data);
32 EAPI void eina_hash_free(Eina_Hash *hash);
33 EAPI int eina_hash_population(const Eina_Hash *hash);
35 EAPI Eina_Bool eina_hash_add_by_hash(Eina_Hash *hash,
36 const void *key, int key_length, int key_hash,
38 EAPI Eina_Bool eina_hash_direct_add_by_hash(Eina_Hash *hash,
39 const void *key, int key_length, int key_hash,
41 EAPI Eina_Bool eina_hash_del_by_hash(Eina_Hash *hash,
42 const void *key, int key_length, int key_hash,
44 EAPI void * eina_hash_find_by_hash(const Eina_Hash *hash,
45 const void *key, int key_length, int key_hash);
46 EAPI void * eina_hash_modify_by_hash(Eina_Hash *hash,
47 const void *key, int key_length, int key_hash,
50 /* FIXME: Should go with iterator support. */
51 typedef Eina_Bool (*Eina_Foreach)(const Eina_Hash *hash, const void *key, void *data, void *fdata);
52 EAPI void eina_hash_foreach(const Eina_Hash *hash,
56 /* Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html) hash function
57 used by WebCore (http://webkit.org/blog/8/hashtables-part-2/) */
58 EAPI int eina_hash_superfast(const char *key, int len);
60 /* Hash function first reported by dan bernstein many years ago in comp.lang.c */
61 static inline int eina_hash_djb2(const char *key, int len);
63 #include "eina_inline_hash.x"
65 #endif /*EINA_HASH_H_*/