nemea-common  1.6.3
cuckoo_hash_v2.h
Go to the documentation of this file.
1 
8 #include <stdint.h>
9 
10 #ifndef CUCKOO_HASH_V2_H
11 #define CUCKOO_HASH_V2_H
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
20 #define REHASH_FAILURE -1
21 
25 #define NOT_FOUND -1
26 
30 typedef struct {
32  uint8_t valid;
33  int index;
36 
40 typedef struct {
43  char **keys;
44  void **data;
45  char *key_kick;
46  void *data_kick;
47  unsigned int data_size;
48  unsigned int table_size;
49  unsigned int key_length;
52 /*
53  * Initialization function for the table.
54  */
55 int ht_init_v2(cc_hash_table_v2_t* new_table, unsigned int table_size, unsigned int data_size, unsigned int key_length);
56 
57 /*
58  * Function for resizing and rehashing the table.
59  */
61 
62 /*
63  * Function for inserting an element.
64  */
65 void* ht_insert_v2(cc_hash_table_v2_t* ht, char *key, const void *new_data);
66 void* ht_lock_insert_v2(cc_hash_table_v2_t *ht, char *key, const void *new_data, void (*lock)(int), void (*unlock)(int));
67 /*
68  * Getters for data/index to item in table.
69  */
70 void *ht_get_v2(cc_hash_table_v2_t* ht, char* key);
71 int ht_get_index_v2(cc_hash_table_v2_t* ht, char* key);
72 
73 /*
74  * Function for checking data validity.
75  */
76 int ht_is_valid_v2(cc_hash_table_v2_t* ht, char* key, int index);
77 
78 /*
79  * Procedures for removing single item from table.
80  */
81 void ht_remove_by_key_v2(cc_hash_table_v2_t* ht, char* key);
82 void ht_remove_precomp_v2(cc_hash_table_v2_t* ht, char* key, unsigned int h1, unsigned int h2, unsigned int h3);
83 
84 /*
85  * Procedure for removing all items from table.
86  */
88 
89 /*
90  * Destructor of the table.
91  */
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif
index_array_t * ind
void ht_remove_precomp_v2(cc_hash_table_v2_t *ht, char *key, unsigned int h1, unsigned int h2, unsigned int h3)
void ht_destroy_v2(cc_hash_table_v2_t *ht)
void * ht_get_v2(cc_hash_table_v2_t *ht, char *key)
int ht_get_index_v2(cc_hash_table_v2_t *ht, char *key)
void ht_remove_by_key_v2(cc_hash_table_v2_t *ht, char *key)
unsigned int key_length
unsigned int table_size
unsigned int data_size
int rehash_v2(cc_hash_table_v2_t *ht)
int ht_init_v2(cc_hash_table_v2_t *new_table, unsigned int table_size, unsigned int data_size, unsigned int key_length)
void * ht_insert_v2(cc_hash_table_v2_t *ht, char *key, const void *new_data)
void * ht_lock_insert_v2(cc_hash_table_v2_t *ht, char *key, const void *new_data, void(*lock)(int), void(*unlock)(int))
int ht_is_valid_v2(cc_hash_table_v2_t *ht, char *key, int index)
void ht_clear_v2(cc_hash_table_v2_t *ht)