Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
khash.h
Go to the documentation of this file.
1/** @file khash.h
2 */
3/* The MIT License
4
5 Copyright (c) 2008, 2009, 2011 by Attractive Chaos <attractor@live.co.uk>
6
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files (the
9 "Software"), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
14
15 The above copyright notice and this permission notice shall be
16 included in all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
22 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 SOFTWARE.
26*/
27
28/*
29 An example:
30
31#include "khash.h"
32KHASH_MAP_INIT_INT(32, char)
33int main() {
34 int ret, is_missing;
35 khiter_t k;
36 khash_t(32) *h = kh_init(32);
37 k = kh_put(32, h, 5, &ret);
38 kh_value(h, k) = 10;
39 k = kh_get(32, h, 10);
40 is_missing = (k == kh_end(h));
41 k = kh_get(32, h, 5);
42 kh_del(32, h, k);
43 for (k = kh_begin(h); k != kh_end(h); ++k)
44 if (kh_exist(h, k)) kh_value(h, k) = 1;
45 kh_destroy(32, h);
46 return 0;
47}
48*/
49
50/*
51 2013-05-02 (0.2.8):
52
53 * Use quadratic probing. When the capacity is power of 2, stepping function
54 i*(i+1)/2 guarantees to traverse each bucket. It is better than double
55 hashing on cache performance and is more robust than linear probing.
56
57 In theory, double hashing should be more robust than quadratic probing.
58 However, my implementation is probably not for large hash tables, because
59 the second hash function is closely tied to the first hash function,
60 which reduce the effectiveness of double hashing.
61
62 Reference: http://research.cs.vt.edu/AVresearch/hashing/quadratic.php
63
64 2011-12-29 (0.2.7):
65
66 * Minor code clean up; no actual effect.
67
68 2011-09-16 (0.2.6):
69
70 * The capacity is a power of 2. This seems to dramatically improve the
71 speed for simple keys. Thank Zilong Tan for the suggestion. Reference:
72
73 - http://code.google.com/p/ulib/
74 - http://nothings.org/computer/judy/
75
76 * Allow to optionally use linear probing which usually has better
77 performance for random input. Double hashing is still the default as it
78 is more robust to certain non-random input.
79
80 * Added Wang's integer hash function (not used by default). This hash
81 function is more robust to certain non-random input.
82
83 2011-02-14 (0.2.5):
84
85 * Allow to declare global functions.
86
87 2009-09-26 (0.2.4):
88
89 * Improve portability
90
91 2008-09-19 (0.2.3):
92
93 * Corrected the example
94 * Improved interfaces
95
96 2008-09-11 (0.2.2):
97
98 * Improved speed a little in kh_put()
99
100 2008-09-10 (0.2.1):
101
102 * Added kh_clear()
103 * Fixed a compiling error
104
105 2008-09-02 (0.2.0):
106
107 * Changed to token concatenation which increases flexibility.
108
109 2008-08-31 (0.1.2):
110
111 * Fixed a bug in kh_get(), which has not been tested previously.
112
113 2008-08-31 (0.1.1):
114
115 * Added destructor
116*/
117
118
119#ifndef __AC_KHASH_H
120#define __AC_KHASH_H
121
122/*!
123 @header
124
125 Generic hash table library.
126 */
127
128#define AC_VERSION_KHASH_H "0.2.8"
129
130#include <stdlib.h>
131#include <string.h>
132#include <stdint.h>
133
136
137#ifndef kh_inline
138#ifdef _MSC_VER
139#define kh_inline __inline
140#else
141#define kh_inline inline
142#endif
143#endif /* kh_inline */
144
145#ifndef klib_unused
146#if (defined __clang__ && __clang_major__ >= 3) || (defined __GNUC__ && __GNUC__ >= 3)
147#define klib_unused __attribute__ ((__unused__))
148#else
149#define klib_unused
150#endif
151#endif /* klib_unused */
152
155
156#define __ac_isempty(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&2)
157#define __ac_isdel(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&1)
158#define __ac_iseither(flag, i) ((flag[i>>4]>>((i&0xfU)<<1))&3)
159#define __ac_set_isdel_false(flag, i) (flag[i>>4]&=~(1ul<<((i&0xfU)<<1)))
160#define __ac_set_isempty_false(flag, i) (flag[i>>4]&=~(2ul<<((i&0xfU)<<1)))
161#define __ac_set_isboth_false(flag, i) (flag[i>>4]&=~(3ul<<((i&0xfU)<<1)))
162#define __ac_set_isdel_true(flag, i) (flag[i>>4]|=1ul<<((i&0xfU)<<1))
163
164#define __ac_fsize(m) ((m) < 16? 1 : (m)>>4)
165
166#ifndef kroundup32
167#define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))
168#endif
169
170#ifndef kcalloc
171#define kcalloc(N,Z) calloc(N,Z)
172#endif
173#ifndef kmalloc
174#define kmalloc(Z) malloc(Z)
175#endif
176#ifndef krealloc
177#define krealloc(P,Z) realloc(P,Z)
178#endif
179#ifndef kfree
180#define kfree(P) free(P)
181#endif
182
183static const double __ac_HASH_UPPER = 0.77;
184
185#define __KHASH_TYPE(name, khkey_t, khval_t) \
186 typedef struct kh_##name##_s { \
187 khint_t n_buckets, size, n_occupied, upper_bound; \
188 khint32_t *flags; \
189 khkey_t *keys; \
190 khval_t *vals; \
191 } kh_##name##_t;
192
193#define __KHASH_PROTOTYPES(name, khkey_t, khval_t) \
194 extern kh_##name##_t *kh_init_##name(void); \
195 extern void kh_destroy_##name(kh_##name##_t *h); \
196 extern void kh_clear_##name(kh_##name##_t *h); \
197 extern khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key); \
198 extern int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets); \
199 extern khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret); \
200 extern void kh_del_##name(kh_##name##_t *h, khint_t x);
201
202#define __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
203 SCOPE kh_##name##_t *kh_init_##name(void) { \
204 return (kh_##name##_t*)kcalloc(1, sizeof(kh_##name##_t)); \
205 } \
206 SCOPE void kh_destroy_##name(kh_##name##_t *h) \
207 { \
208 if (h) { \
209 kfree((void *)h->keys); kfree(h->flags); \
210 kfree((void *)h->vals); \
211 kfree(h); \
212 } \
213 } \
214 SCOPE void kh_clear_##name(kh_##name##_t *h) \
215 { \
216 if (h && h->flags) { \
217 memset(h->flags, 0xaa, __ac_fsize(h->n_buckets) * sizeof(khint32_t)); \
218 h->size = h->n_occupied = 0; \
219 } \
220 } \
221 SCOPE khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key) \
222 { \
223 if (h->n_buckets) { \
224 khint_t k, i, last, mask, step = 0; \
225 mask = h->n_buckets - 1; \
226 k = __hash_func(key); i = k & mask; \
227 last = i; \
228 while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \
229 i = (i + (++step)) & mask; \
230 if (i == last) return h->n_buckets; \
231 } \
232 return __ac_iseither(h->flags, i)? h->n_buckets : i; \
233 } else return 0; \
234 } \
235 SCOPE int kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \
236 { /* This function uses 0.25*n_buckets bytes of working space instead of [sizeof(key_t+val_t)+.25]*n_buckets. */ \
237 khint32_t *new_flags = 0; \
238 khint_t j = 1; \
239 { \
240 kroundup32(new_n_buckets); \
241 if (new_n_buckets < 4) new_n_buckets = 4; \
242 if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER + 0.5)) j = 0; /* requested size is too small */ \
243 else { /* hash table size to be changed (shrink or expand); rehash */ \
244 new_flags = (khint32_t*)kmalloc(__ac_fsize(new_n_buckets) * sizeof(khint32_t)); \
245 if (!new_flags) return -1; \
246 memset(new_flags, 0xaa, __ac_fsize(new_n_buckets) * sizeof(khint32_t)); \
247 if (h->n_buckets < new_n_buckets) { /* expand */ \
248 khkey_t *new_keys = (khkey_t*)krealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \
249 if (!new_keys) { kfree(new_flags); return -1; } \
250 h->keys = new_keys; \
251 if (kh_is_map) { \
252 khval_t *new_vals = (khval_t*)krealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \
253 if (!new_vals) { kfree(new_flags); return -1; } \
254 h->vals = new_vals; \
255 } \
256 } /* otherwise shrink */ \
257 } \
258 } \
259 if (j) { /* rehashing is needed */ \
260 for (j = 0; j != h->n_buckets; ++j) { \
261 if (__ac_iseither(h->flags, j) == 0) { \
262 khkey_t key = h->keys[j]; \
263 khval_t val; \
264 khint_t new_mask; \
265 new_mask = new_n_buckets - 1; \
266 if (kh_is_map) val = h->vals[j]; \
267 __ac_set_isdel_true(h->flags, j); \
268 while (1) { /* kick-out process; sort of like in Cuckoo hashing */ \
269 khint_t k, i, step = 0; \
270 k = __hash_func(key); \
271 i = k & new_mask; \
272 while (!__ac_isempty(new_flags, i)) i = (i + (++step)) & new_mask; \
273 __ac_set_isempty_false(new_flags, i); \
274 if (i < h->n_buckets && __ac_iseither(h->flags, i) == 0) { /* kick out the existing element */ \
275 { khkey_t tmp = h->keys[i]; h->keys[i] = key; key = tmp; } \
276 if (kh_is_map) { khval_t tmp = h->vals[i]; h->vals[i] = val; val = tmp; } \
277 __ac_set_isdel_true(h->flags, i); /* mark it as deleted in the old hash table */ \
278 } else { /* write the element and jump out of the loop */ \
279 h->keys[i] = key; \
280 if (kh_is_map) h->vals[i] = val; \
281 break; \
282 } \
283 } \
284 } \
285 } \
286 if (h->n_buckets > new_n_buckets) { /* shrink the hash table */ \
287 h->keys = (khkey_t*)krealloc((void *)h->keys, new_n_buckets * sizeof(khkey_t)); \
288 if (kh_is_map) h->vals = (khval_t*)krealloc((void *)h->vals, new_n_buckets * sizeof(khval_t)); \
289 } \
290 kfree(h->flags); /* free the working space */ \
291 h->flags = new_flags; \
292 h->n_buckets = new_n_buckets; \
293 h->n_occupied = h->size; \
294 h->upper_bound = (khint_t)(h->n_buckets * __ac_HASH_UPPER + 0.5); \
295 } \
296 return 0; \
297 } \
298 SCOPE khint_t kh_put_##name(kh_##name##_t *h, khkey_t key, int *ret) \
299 { \
300 khint_t x; \
301 if (h->n_occupied >= h->upper_bound) { /* update the hash table */ \
302 if (h->n_buckets > (h->size<<1)) { \
303 if (kh_resize_##name(h, h->n_buckets - 1) < 0) { /* clear "deleted" elements */ \
304 *ret = -1; return h->n_buckets; \
305 } \
306 } else if (kh_resize_##name(h, h->n_buckets + 1) < 0) { /* expand the hash table */ \
307 *ret = -1; return h->n_buckets; \
308 } \
309 } /* TODO: to implement automatically shrinking; resize() already support shrinking */ \
310 { \
311 khint_t k, i, site, last, mask = h->n_buckets - 1, step = 0; \
312 x = site = h->n_buckets; k = __hash_func(key); i = k & mask; \
313 if (__ac_isempty(h->flags, i)) x = i; /* for speed up */ \
314 else { \
315 last = i; \
316 while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \
317 if (__ac_isdel(h->flags, i)) site = i; \
318 i = (i + (++step)) & mask; \
319 if (i == last) { x = site; break; } \
320 } \
321 if (x == h->n_buckets) { \
322 if (__ac_isempty(h->flags, i) && site != h->n_buckets) x = site; \
323 else x = i; \
324 } \
325 } \
326 } \
327 if (__ac_isempty(h->flags, x)) { /* not present at all */ \
328 h->keys[x] = key; \
329 __ac_set_isboth_false(h->flags, x); \
330 ++h->size; ++h->n_occupied; \
331 *ret = 1; \
332 } else if (__ac_isdel(h->flags, x)) { /* deleted */ \
333 h->keys[x] = key; \
334 __ac_set_isboth_false(h->flags, x); \
335 ++h->size; \
336 *ret = 2; \
337 } else *ret = 0; /* Don't touch h->keys[x] if present and not deleted */ \
338 return x; \
339 } \
340 SCOPE void kh_del_##name(kh_##name##_t *h, khint_t x) \
341 { \
342 if (x != h->n_buckets && !__ac_iseither(h->flags, x)) { \
343 __ac_set_isdel_true(h->flags, x); \
344 --h->size; \
345 } \
346 }
347
348#define KHASH_DECLARE(name, khkey_t, khval_t) \
349 __KHASH_TYPE(name, khkey_t, khval_t) \
350 __KHASH_PROTOTYPES(name, khkey_t, khval_t)
351
352#define KHASH_INIT2(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
353 __KHASH_TYPE(name, khkey_t, khval_t) \
354 __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
355
356#define KHASH_INIT(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
357 KHASH_INIT2(name, static kh_inline klib_unused, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
358
359/* --- BEGIN OF HASH FUNCTIONS --- */
360
361/*! @function
362 @abstract Integer hash function
363 @param key The integer [khint32_t]
364 @return The hash value [khint_t]
365 */
366#define kh_int_hash_func(key) (khint32_t)(key)
367/*! @function
368 @abstract Integer comparison function
369 */
370#define kh_int_hash_equal(a, b) ((a) == (b))
371/*! @function
372 @abstract 64-bit integer hash function
373 @param key The integer [khint64_t]
374 @return The hash value [khint_t]
375 */
376#define kh_int64_hash_func(key) (khint32_t)((key)>>33^(key)^(key)<<11)
377/*! @function
378 @abstract 64-bit integer comparison function
379 */
380#define kh_int64_hash_equal(a, b) ((a) == (b))
381/*! @function
382 @abstract const char* hash function
383 @param s Pointer to a null terminated string
384 @return The hash value
385 */
387{
388 khint_t h = (khint_t)*s;
389 if (h) for (++s ; *s; ++s) h = (h << 5) - h + (khint_t)*s;
390 return h;
391}
392/*! @function
393 @abstract Another interface to const char* hash function
394 @param key Pointer to a null terminated string [const char*]
395 @return The hash value [khint_t]
396 */
397#define kh_str_hash_func(key) __ac_X31_hash_string(key)
398/*! @function
399 @abstract Const char* comparison function
400 */
401#define kh_str_hash_equal(a, b) (strcmp(a, b) == 0)
402
404{
405 key += ~(key << 15);
406 key ^= (key >> 10);
407 key += (key << 3);
408 key ^= (key >> 6);
409 key += ~(key << 11);
410 key ^= (key >> 16);
411 return key;
412}
413#define kh_int_hash_func2(key) __ac_Wang_hash((khint_t)key)
414
415/* --- END OF HASH FUNCTIONS --- */
416
417/* Other convenient macros... */
418
419/*!
420 @abstract Type of the hash table.
421 @param name Name of the hash table [symbol]
422 */
423#define khash_t(name) kh_##name##_t
424
425/*! @function
426 @abstract Initiate a hash table.
427 @param name Name of the hash table [symbol]
428 @return Pointer to the hash table [khash_t(name)*]
429 */
430#define kh_init(name) kh_init_##name()
431
432/*! @function
433 @abstract Destroy a hash table.
434 @param name Name of the hash table [symbol]
435 @param h Pointer to the hash table [khash_t(name)*]
436 */
437#define kh_destroy(name, h) kh_destroy_##name(h)
438
439/*! @function
440 @abstract Reset a hash table without deallocating memory.
441 @param name Name of the hash table [symbol]
442 @param h Pointer to the hash table [khash_t(name)*]
443 */
444#define kh_clear(name, h) kh_clear_##name(h)
445
446/*! @function
447 @abstract Resize a hash table.
448 @param name Name of the hash table [symbol]
449 @param h Pointer to the hash table [khash_t(name)*]
450 @param s New size [khint_t]
451 */
452#define kh_resize(name, h, s) kh_resize_##name(h, s)
453
454/*! @function
455 @abstract Insert a key to the hash table.
456 @param name Name of the hash table [symbol]
457 @param h Pointer to the hash table [khash_t(name)*]
458 @param k Key [type of keys]
459 @param r Extra return code: -1 if the operation failed;
460 0 if the key is present in the hash table;
461 1 if the bucket is empty (never used); 2 if the element in
462 the bucket has been deleted [int*]
463 @return Iterator to the inserted element [khint_t]
464 */
465#define kh_put(name, h, k, r) kh_put_##name(h, k, r)
466
467/*! @function
468 @abstract Retrieve a key from the hash table.
469 @param name Name of the hash table [symbol]
470 @param h Pointer to the hash table [khash_t(name)*]
471 @param k Key [type of keys]
472 @return Iterator to the found element, or kh_end(h) if the element is absent [khint_t]
473 */
474#define kh_get(name, h, k) kh_get_##name(h, k)
475
476/*! @function
477 @abstract Remove a key from the hash table.
478 @param name Name of the hash table [symbol]
479 @param h Pointer to the hash table [khash_t(name)*]
480 @param k Iterator to the element to be deleted [khint_t]
481 */
482#define kh_del(name, h, k) kh_del_##name(h, k)
483
484/*! @function
485 @abstract Test whether a bucket contains data.
486 @param h Pointer to the hash table [khash_t(name)*]
487 @param x Iterator to the bucket [khint_t]
488 @return 1 if containing data; 0 otherwise [int]
489 */
490#define kh_exist(h, x) (!__ac_iseither((h)->flags, (x)))
491
492/*! @function
493 @abstract Get key given an iterator
494 @param h Pointer to the hash table [khash_t(name)*]
495 @param x Iterator to the bucket [khint_t]
496 @return Key [type of keys]
497 */
498#define kh_key(h, x) ((h)->keys[x])
499
500/*! @function
501 @abstract Get value given an iterator
502 @param h Pointer to the hash table [khash_t(name)*]
503 @param x Iterator to the bucket [khint_t]
504 @return Value [type of values]
505 @discussion For hash sets, calling this results in segfault.
506 */
507#define kh_val(h, x) ((h)->vals[x])
508
509/*! @function
510 @abstract Alias of kh_val()
511 */
512#define kh_value(h, x) ((h)->vals[x])
513
514/*! @function
515 @abstract Get the start iterator
516 @param h Pointer to the hash table [khash_t(name)*]
517 @return The start iterator [khint_t]
518 */
519#define kh_begin(h) (khint_t)(0)
520
521/*! @function
522 @abstract Get the end iterator
523 @param h Pointer to the hash table [khash_t(name)*]
524 @return The end iterator [khint_t]
525 */
526#define kh_end(h) ((h)->n_buckets)
527
528/*! @function
529 @abstract Get the number of elements in the hash table
530 @param h Pointer to the hash table [khash_t(name)*]
531 @return Number of elements in the hash table [khint_t]
532 */
533#define kh_size(h) ((h)->size)
534
535/*! @function
536 @abstract Get the number of buckets in the hash table
537 @param h Pointer to the hash table [khash_t(name)*]
538 @return Number of buckets in the hash table [khint_t]
539 */
540#define kh_n_buckets(h) ((h)->n_buckets)
541
542/*! @function
543 @abstract Iterate over the entries in the hash table
544 @param h Pointer to the hash table [khash_t(name)*]
545 @param kvar Variable to which key will be assigned
546 @param vvar Variable to which value will be assigned
547 @param code Block of code to execute
548 */
549#define kh_foreach(h, kvar, vvar, code) { khint_t __i; \
550 for (__i = kh_begin(h); __i != kh_end(h); ++__i) { \
551 if (!kh_exist(h,__i)) continue; \
552 (kvar) = kh_key(h,__i); \
553 (vvar) = kh_val(h,__i); \
554 code; \
555 } }
556
557/*! @function
558 @abstract Iterate over the values in the hash table
559 @param h Pointer to the hash table [khash_t(name)*]
560 @param vvar Variable to which value will be assigned
561 @param code Block of code to execute
562 */
563#define kh_foreach_value(h, vvar, code) { khint_t __i; \
564 for (__i = kh_begin(h); __i != kh_end(h); ++__i) { \
565 if (!kh_exist(h,__i)) continue; \
566 (vvar) = kh_val(h,__i); \
567 code; \
568 } }
569
570/* More convenient interfaces */
571
572/*! @function
573 @abstract Instantiate a hash set containing integer keys
574 @param name Name of the hash table [symbol]
575 */
576#define KHASH_SET_INIT_INT(name) \
577 KHASH_INIT(name, khint32_t, char, 0, kh_int_hash_func, kh_int_hash_equal)
578
579/*! @function
580 @abstract Instantiate a hash map containing integer keys
581 @param name Name of the hash table [symbol]
582 @param khval_t Type of values [type]
583 */
584#define KHASH_MAP_INIT_INT(name, khval_t) \
585 KHASH_INIT(name, khint32_t, khval_t, 1, kh_int_hash_func, kh_int_hash_equal)
586
587/*! @function
588 @abstract Instantiate a hash set containing 64-bit integer keys
589 @param name Name of the hash table [symbol]
590 */
591#define KHASH_SET_INIT_INT64(name) \
592 KHASH_INIT(name, khint64_t, char, 0, kh_int64_hash_func, kh_int64_hash_equal)
593
594/*! @function
595 @abstract Instantiate a hash map containing 64-bit integer keys
596 @param name Name of the hash table [symbol]
597 @param khval_t Type of values [type]
598 */
599#define KHASH_MAP_INIT_INT64(name, khval_t) \
600 KHASH_INIT(name, khint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
601
602typedef const char *kh_cstr_t;
603/*! @function
604 @abstract Instantiate a hash map containing const char* keys
605 @param name Name of the hash table [symbol]
606 */
607#define KHASH_SET_INIT_STR(name) \
608 KHASH_INIT(name, kh_cstr_t, char, 0, kh_str_hash_func, kh_str_hash_equal)
609
610/*! @function
611 @abstract Instantiate a hash map containing const char* keys
612 @param name Name of the hash table [symbol]
613 @param khval_t Type of values [type]
614 */
615#define KHASH_MAP_INIT_STR(name, khval_t) \
616 KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_str_hash_func, kh_str_hash_equal)
617
618#endif /* __AC_KHASH_H */
scalar h[]
Definition atmosphere.h:6
int x
Definition common.h:76
scalar s
Definition embed-tree.h:56
const char * kh_cstr_t
Definition khash.h:602
static const double __ac_HASH_UPPER
Definition khash.h:183
khint_t khiter_t
Definition khash.h:154
khint32_t khint_t
Definition khash.h:153
static khint_t __ac_X31_hash_string(const char *s)
Definition khash.h:386
static khint_t __ac_Wang_hash(khint_t key)
Definition khash.h:403
#define kh_inline
Definition khash.h:141
uint64_t khint64_t
Definition khash.h:135
uint32_t khint32_t
Definition khash.h:134