~lattis/muon

ref: f9a8cbad39b665a9496cd3adb4756e85ee5ec97c muon/include/data/hash.h -rw-r--r-- 778 bytes
f9a8cbadStone Tickle print stdout/stderr of failing test 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef MUON_DATA_HASH_H
#define MUON_DATA_HASH_H

#include <stddef.h>
#include <stdint.h>

#include "darr.h"
#include "iterator.h"

struct hash {
	struct darr meta, e, keys;
	size_t cap, len, load, max_load, capm;
};

typedef enum iteration_result ((*hash_with_keys_iterator_func)(void *ctx, const char *key, uint64_t val));

void hash_init(struct hash *h, size_t cap);
void hash_destroy(struct hash *h);

uint64_t *hash_get(const struct hash *h, const char *key);
void hash_set(struct hash *h, const char *key, uint64_t val);
void hash_unset(struct hash *h, const char *key);
void hash_clear(struct hash *h);

void hash_for_each(struct hash *h, void *ctx, iterator_func ifnc);
void hash_for_each_with_keys(struct hash *h, void *ctx, hash_with_keys_iterator_func ifnc);
#endif