hat-util 0.6.19
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
35
40
46
56int hat_ht_set(hat_ht_t *t, void *key, size_t key_size, void *value);
57
64void *hat_ht_get(hat_ht_t *t, void *key, size_t key_size);
65
72void *hat_ht_pop(hat_ht_t *t, void *key, size_t key_size);
73
80int hat_ht_del(hat_ht_t *t, void *key, size_t key_size);
81
91
97
103
109
110#ifdef __cplusplus
111}
112#endif
113#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.
hat_ht_t * hat_ht_create(hat_allocator_t *a)
Create new hash 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.
void * hat_ht_iter_t
Hash table iterator.
Definition ht.h:26
void * hat_ht_iter_key(hat_ht_iter_t i)
Get current key.
Allocator base struct.
Definition allocator.h:36