MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
genhash.h
1 /*
2  * Generic hash table implementation.
3  *
4  * Copyright (c) 2006 Dustin Sallings <dustin@spy.net>
5  */
6 
7 #ifndef GENHASH_H
8 #define GENHASH_H 1
9 
10 #include <memcached/visibility.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
40 struct hash_ops {
44  int (*hashfunc)(const void *, size_t);
48  int (*hasheq)(const void *, size_t, const void *, size_t);
52  void* (*dupKey)(const void *, size_t);
56  void* (*dupValue)(const void *, size_t);
60  void (*freeKey)(void *);
64  void (*freeValue)(void *);
65 };
66 
70 typedef struct _genhash genhash_t ;
71 
77  NEW
78 };
79 
88 MEMCACHED_PUBLIC_API
89 genhash_t* genhash_init(int est, struct hash_ops ops);
90 
96 MEMCACHED_PUBLIC_API
97 void genhash_free(genhash_t *h);
98 
106 MEMCACHED_PUBLIC_API
107 void genhash_store(genhash_t *h, const void *k, size_t klen,
108  const void *v, size_t vlen);
109 
118 MEMCACHED_PUBLIC_API
119 void* genhash_find(genhash_t *h, const void *k, size_t klen);
120 
129 MEMCACHED_PUBLIC_API
130 int genhash_delete(genhash_t *h, const void *k, size_t klen);
131 
140 MEMCACHED_PUBLIC_API
141 int genhash_delete_all(genhash_t *h, const void *k, size_t klen);
142 
153 MEMCACHED_PUBLIC_API
154 enum update_type genhash_update(genhash_t *h, const void *k, size_t klen,
155  const void *v, size_t vlen);
156 
171 MEMCACHED_PUBLIC_API
172 enum update_type genhash_fun_update(genhash_t *h, const void *key, size_t klen,
173  void *(*upd)(const void *k, const void *oldv,
174  size_t *ns, void *a),
175  void (*fr)(void*),
176  void *arg,
177  const void *def, size_t deflen);
178 
186 MEMCACHED_PUBLIC_API
187 void genhash_iter(genhash_t *h,
188  void (*iterfunc)(const void* key, size_t nkey,
189  const void* val, size_t nval,
190  void *arg),
191  void *arg);
192 
201 MEMCACHED_PUBLIC_API
202 void genhash_iter_key(genhash_t *h, const void* key, size_t nkey,
203  void (*iterfunc)(const void* key, size_t inkey,
204  const void* val, size_t inval,
205  void *arg),
206  void *arg);
207 
215 MEMCACHED_PUBLIC_API
216 int genhash_size(genhash_t *h);
217 
225 MEMCACHED_PUBLIC_API
226 int genhash_clear(genhash_t *h);
227 
237 MEMCACHED_PUBLIC_API
238 int genhash_size_for_key(genhash_t *h, const void *k, size_t nkey);
239 
247 MEMCACHED_PUBLIC_API
248 int genhash_string_hash(const void *k, size_t nkey);
249 
253 #ifdef __cplusplus
254 }
255 #endif /* __cplusplus */
256 #endif /* GENHASH_H */