nemea-common 1.6.3
Data Structures | Macros | Functions
cuckoo_hash.h File Reference

Generic hash table with Cuckoo hashing support – header file. More...

Go to the source code of this file.

Data Structures

struct  cc_item_t
 
struct  cc_hash_table_t
 

Macros

#define REHASH_FAILURE   -1
 
#define NOT_FOUND   -1
 
#define INSERT_FAILURE   -2
 
#define REHASH_ENABLE   1
 
#define REHASH_DISABLE   0
 

Functions

int ht_init (cc_hash_table_t *new_table, unsigned int table_size, unsigned int data_size, unsigned int key_length, int rehash)
 
int rehash (cc_hash_table_t *ht, cc_item_t *rest)
 
int ht_insert (cc_hash_table_t *ht, char *key, const void *new_data, unsigned int n_key_length)
 
int ht_is_empty (cc_hash_table_t *ht)
 
void * ht_get (cc_hash_table_t *ht, char *key, unsigned int key_length)
 
int ht_get_index (cc_hash_table_t *ht, char *key, unsigned int key_length)
 
void ht_remove_by_key (cc_hash_table_t *ht, char *key, unsigned int key_length)
 
void ht_remove_by_index (cc_hash_table_t *ht, unsigned int index)
 
void ht_clear (cc_hash_table_t *ht)
 
void ht_destroy (cc_hash_table_t *ht)
 

Detailed Description

Generic hash table with Cuckoo hashing support – header file.

Author
Roman Vrana xvran.nosp@m.a20@.nosp@m.stud..nosp@m.fit..nosp@m.vutbr.nosp@m..cz
Date
2013
2014

Definition in file cuckoo_hash.h.

Macro Definition Documentation

◆ INSERT_FAILURE

#define INSERT_FAILURE   -2

Error constant returned by insert function when failing due no memory

Definition at line 65 of file cuckoo_hash.h.

◆ NOT_FOUND

#define NOT_FOUND   -1

Constant return by index getter when an item is not found.

Definition at line 60 of file cuckoo_hash.h.

◆ REHASH_DISABLE

#define REHASH_DISABLE   0

Initialization constant for disabling rehash feature. Last item that was kicked will be dropped permanently.

Definition at line 77 of file cuckoo_hash.h.

◆ REHASH_ENABLE

#define REHASH_ENABLE   1

Initialization constant for enabling rehash feature. After unsuccesful insert the table will be rehashed automatically.

Definition at line 71 of file cuckoo_hash.h.

◆ REHASH_FAILURE

#define REHASH_FAILURE   -1

Error constant returned by rehashing function when failing.

Definition at line 55 of file cuckoo_hash.h.

Function Documentation

◆ ht_clear()

void ht_clear ( cc_hash_table_t * ht)

◆ ht_destroy()

void ht_destroy ( cc_hash_table_t * ht)

◆ ht_get()

void * ht_get ( cc_hash_table_t * ht,
char * key,
unsigned int key_length )

◆ ht_get_index()

int ht_get_index ( cc_hash_table_t * ht,
char * key,
unsigned int key_length )

◆ ht_init()

int ht_init ( cc_hash_table_t * new_table,
unsigned int table_size,
unsigned int data_size,
unsigned int key_length,
int rehash )

◆ ht_insert()

int ht_insert ( cc_hash_table_t * ht,
char * key,
const void * new_data,
unsigned int n_key_length )

◆ ht_is_empty()

int ht_is_empty ( cc_hash_table_t * ht)

◆ ht_remove_by_index()

void ht_remove_by_index ( cc_hash_table_t * ht,
unsigned int index )

◆ ht_remove_by_key()

void ht_remove_by_key ( cc_hash_table_t * ht,
char * key,
unsigned int key_length )

◆ rehash()

int rehash ( cc_hash_table_t * ht,
cc_item_t * rest )