hat-util 0.6.18
Utility library
ht.h
Go to the documentation of this file.
1#ifndef HAT_HT_H
2#define HAT_HT_H
3
11#include <stddef.h>
12#include <stdint.h>
13#include "allocator.h"
14
15#define HAT_HT_SUCCESS 0
16#define HAT_HT_ERROR (-1)
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
23typedef struct hat_ht_t hat_ht_t;
24
26typedef void *hat_ht_iter_t;
27
28
34hat_ht_t *hat_ht_create(hat_allocator_t *a, size_t avg_count);
35
40
46int hat_ht_resize(hat_ht_t *t, size_t avg_count);
47
53
59
69int hat_ht_set(hat_ht_t *t, void *key, size_t key_size, void *value);
70
77void *hat_ht_get(hat_ht_t *t, void *key, size_t key_size);
78
85void *hat_ht_pop(hat_ht_t *t, void *key, size_t key_size);
86
93int hat_ht_del(hat_ht_t *t, void *key, size_t key_size);
94
104
110
116
122
123#ifdef __cplusplus
124}
125#endif
126#endif
Memory allocator.
size_t hat_ht_iter_key_size(hat_ht_iter_t i)
Get current key size.
size_t hat_ht_count(hat_ht_t *t)
Number of elements in table.
void * hat_ht_iter_value(hat_ht_iter_t i)
Get current value.
size_t hat_ht_avg_count(hat_ht_t *t)
Initially estimated number of elements in table.
void hat_ht_destroy(hat_ht_t *t)
Destroy hash table.
int hat_ht_del(hat_ht_t *t, void *key, size_t key_size)
Delete element from table.
void * hat_ht_pop(hat_ht_t *t, void *key, size_t key_size)
Pop element from table.
int hat_ht_set(hat_ht_t *t, void *key, size_t key_size, void *value)
Set element in table.
void * hat_ht_get(hat_ht_t *t, void *key, size_t key_size)
Get element from table.
struct hat_ht_t hat_ht_t
Hash table.
Definition ht.h:23
hat_ht_iter_t hat_ht_iter_next(hat_ht_t *t, hat_ht_iter_t prev)
Get next iterator position.
int hat_ht_resize(hat_ht_t *t, size_t avg_count)
Reallocate hash table based on new average count.
void * hat_ht_iter_t
Hash table iterator.
Definition ht.h:26
hat_ht_t * hat_ht_create(hat_allocator_t *a, size_t avg_count)
Create new hash table.
void * hat_ht_iter_key(hat_ht_iter_t i)
Get current key.
Allocator base struct.
Definition allocator.h:36