Skip to content

Commit

Permalink
added kh_exist()
Browse files Browse the repository at this point in the history
  • Loading branch information
attractivechaos committed Jul 16, 2021
1 parent e1b2a40 commit 9a063b3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion khashl.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static kh_inline khint_t __kh_h2b(khint_t hash, khint_t bits) { return hash * 26
*******************/

#define __KHASHL_TYPE(HType, khkey_t) \
typedef struct { \
typedef struct HType { \
khint_t bits, count; \
khint32_t *used; \
khkey_t *keys; \
Expand Down Expand Up @@ -264,6 +264,7 @@ static kh_inline khint_t __kh_h2b(khint_t hash, khint_t bits) { return hash * 26
KHASHL_INIT(KH_LOCAL, HType, prefix##_s, HType##_s_bucket_t, prefix##_s_hash, prefix##_s_eq) \
SCOPE HType *prefix##_init(void) { return prefix##_s_init(); } \
SCOPE void prefix##_destroy(HType *h) { prefix##_s_destroy(h); } \
SCOPE void prefix##_resize(HType *h, khint_t new_n_buckets) { prefix##_s_resize(h, new_n_buckets); } \
SCOPE khint_t prefix##_get(const HType *h, khkey_t key) { HType##_s_bucket_t t; t.key = key; return prefix##_s_getp(h, &t); } \
SCOPE int prefix##_del(HType *h, khint_t k) { return prefix##_s_del(h, k); } \
SCOPE khint_t prefix##_put(HType *h, khkey_t key, int *absent) { HType##_s_bucket_t t; t.key = key; return prefix##_s_putp(h, &t, absent); }
Expand Down Expand Up @@ -310,6 +311,7 @@ static kh_inline khint_t __kh_h2b(khint_t hash, khint_t bits) { return hash * 26

#define kh_key(h, x) ((h)->keys[x].key)
#define kh_val(h, x) ((h)->keys[x].val)
#define kh_exist(h, x) __kh_used((h)->used, (x))

/**************************************
* Common hash and equality functions *
Expand Down

0 comments on commit 9a063b3

Please sign in to comment.