ToolBox Library 2.1.0
An Library containing function and class to make developing in C faster
hashtable.h
1#ifndef TOOLBOX_HASHTABLE_H
2#define TOOLBOX_HASHTABLE_H
3
4#include "toolbox/return_codes.h"
5
6#include <stdbool.h>
7#include <stddef.h>
8#include <stdint.h>
9
10#ifndef HASHTABLE_SIZE_BYTES
11#define HASHTABLE_SIZE_BYTES (1024*1024)
12#endif
13
14#ifdef TOOLBOX_TYPEDEF
15typedef struct hashtable hashtable_st;
16#endif
17
18struct hashtable;
19
20__attribute__((__pure__))
21struct hashtable *
22hashtable_create(void);
23
24RET_TYPE
25hashtable_destroy(struct hashtable **self);
26
27__attribute__((__pure__))
28bool
29hashtable_contain_item(const struct hashtable *self
30 , const void* item, const size_t item_size);
31
32__attribute__((__pure__))
33bool
34hashtable_contain_key(const struct hashtable *self
35 , const char *key);
36
37__attribute__((__pure__))
38bool
39hashtable_contain_key_hash(const struct hashtable *self
40 , const size_t key_hash);
41
42__attribute__((__pure__))
43const void *
44hashtable_get(const struct hashtable *self
45 , const char *key);
46
47__attribute__((__pure__))
48const void *
49hashtable_get_or_default(const struct hashtable *self
50 , const char *key
51 , const void *default_item);
52
53__attribute__((__pure__))
54bool
55hashtable_is_empty(const struct hashtable *self);
56
57RET_TYPE
58hashtable_put(struct hashtable *self
59 , const char *key
60 , const void *item, const size_t item_size);
61
62const void *
63hashtable_remove(struct hashtable *self, const char *key);
64
65bool
66hashtable_remove_if_equal(struct hashtable *self
67 , const char *key
68 , const void *item, const size_t item_size);
69
70const void *
71hashtable_replace(struct hashtable *self
72 , const char *key
73 , const void *item, const size_t item_size);
74
75bool
76hashtable_replace_if_equal(struct hashtable *self
77 , const char *key
78 , const void *restrict old_item
79 , const size_t item_old_size
80 , const void *restrict new_item
81 , const size_t item_new_size);
82
83size_t
84hashtable_used_size(const struct hashtable *self);
85
86RET_TYPE
87hashtable_for_each(struct hashtable *self
88 , void (*for_each)(void *item, size_t *item_size));
89
90#endif
Definition: hashtable.c:29