-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjak_ht.h
53 lines (39 loc) · 1.08 KB
/
jak_ht.h
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef jak_ht_h
#define jak_ht_h
/**
* @file
* @brief Hashtable class
*
* All functions that return int return 0 on success if not specified otherwise
*/
#include <stdint.h>
/**
* The main opaque hashtable type.
*/
typedef struct jak_ht jak_ht_t;
/**
* Creates a new hashtable object.
*
* \Returns NULL on error.
*/
jak_ht_t * jak_ht_new(
unsigned int initial_buckets_count,
float growth_factor,
int (*compare_keys)( void * key1, void * key2 ), /**< Should return 0 if keys differ
and 1 otherwise */
uint32_t (*key_to_hash)( void * key ),
void (*destructor)( void * key, void * value ) /**< Can be NULL */
);
/**
* Frees all the memory associated with the ht object created via jak_ht_new() and deallocates it.
*/
void jak_ht_free( jak_ht_t * ht );
/**
* Pushes a new element to the hashtable or assigns the value to an existing one.
*/
int jak_ht_set( jak_ht_t * ht, void * key, void * value );
/**
* \Returns the element identified by the key or NULL if no matching elements are found.
*/
void * jak_ht_get( jak_ht_t * ht, void * key );
#endif