3 KHASH_MAP_INIT_STR(str2id, int)
5 void *bcf_build_refhash(bcf_hdr_t *h)
9 hash = kh_init(str2id);
10 for (i = 0; i < h->n_ref; ++i) {
12 k = kh_put(str2id, hash, h->ns[i], &ret); // FIXME: check ret
18 void *bcf_str2id_init()
20 return kh_init(str2id);
23 void bcf_str2id_destroy(void *_hash)
25 khash_t(str2id) *hash = (khash_t(str2id)*)_hash;
26 if (hash) kh_destroy(str2id, hash); // Note that strings are not freed.
29 int bcf_str2id(void *_hash, const char *str)
31 khash_t(str2id) *hash = (khash_t(str2id)*)_hash;
34 k = kh_get(str2id, hash, str);
35 return k == kh_end(hash)? -1 : kh_val(hash, k);
38 int bcf_str2id_add(void *_hash, const char *str)
42 khash_t(str2id) *hash = (khash_t(str2id)*)_hash;
44 k = kh_put(str2id, hash, str, &ret);
45 if (ret == 0) return kh_val(hash, k);
46 kh_val(hash, k) = kh_size(hash) - 1;
47 return kh_val(hash, k);