HTLIB
C Hash Table Library
Loading...
Searching...
No Matches
htlib.h
Go to the documentation of this file.
1
5
6#ifndef _HTLIB_H_
7#define _HTLIB_H_
8
9#include <stdbool.h>
10#include <stddef.h>
11
22typedef enum {
23 HT_KEY_TYPE_INT,
24 HT_KEY_TYPE_UINT,
25 HT_KEY_TYPE_DOUBLE,
26 HT_KEY_TYPE_STRING,
28
44typedef enum {
45 HT_VALUE_TYPE_INT,
46 HT_VALUE_TYPE_UINT,
47 HT_VALUE_TYPE_DOUBLE,
48 HT_VALUE_TYPE_STRING,
49 HT_VALUE_TYPE_PTR
51
52
59typedef struct ht_hashmap ht_hashmap_t;
60
70 size_t initial_capacity);
71
80bool ht_insert(ht_hashmap_t *ht, const void *key, const void *value);
81
90bool ht_get(ht_hashmap_t *ht, const void *key, void *value_out);
91
99bool ht_remove(ht_hashmap_t *ht, const void *key);
100
108
116
123
130
131#endif // _HTLIB_H_
ht_key_type_t
Type of the hashmap key.
Definition htlib.h:22
bool ht_get(ht_hashmap_t *ht, const void *key, void *value_out)
Gets the value associated with a key.
void ht_destroy(ht_hashmap_t *ht)
Destroys the hashmap.
struct ht_hashmap ht_hashmap_t
Opaque type for the hashmap.
Definition htlib.h:59
size_t ht_size(ht_hashmap_t *ht)
Gets the number of elements in the hashmap.
bool ht_insert(ht_hashmap_t *ht, const void *key, const void *value)
Inserts a key-value pair into the hashmap.
void ht_clear(ht_hashmap_t *ht)
Clears all elements from the hashmap.
ht_hashmap_t * ht_new(ht_key_type_t key_type, ht_value_type_t value_type, size_t initial_capacity)
Creates a new hashmap.
bool ht_remove(ht_hashmap_t *ht, const void *key)
Removes a key-value pair from the hashmap.
ht_value_type_t
Type of the hashmap value.
Definition htlib.h:44
bool ht_is_empty(ht_hashmap_t *ht)
Checks if the hashmap is empty.