cdcontainers  0.1.1
Library of data containers and collections for C programming language.
Functions

Functions

void cdc_hash_table_clear (struct cdc_hash_table *t)
 Removes all the elements from the hash_table. More...
 
enum cdc_stat cdc_hash_table_insert (struct cdc_hash_table *t, void *key, void *value, struct cdc_hash_table_iter *it, bool *inserted)
 Inserts an element into the container, if the container doesn't already contain an element with an equivalent key. More...
 
enum cdc_stat cdc_hash_table_insert_or_assign (struct cdc_hash_table *t, void *key, void *value, struct cdc_hash_table_iter *it, bool *inserted)
 Inserts an element or assigns to the current element if the key already exists. More...
 
size_t cdc_hash_table_erase (struct cdc_hash_table *t, void *key)
 Removes the element (if one exists) with the key equivalent to key. More...
 
void cdc_hash_table_swap (struct cdc_hash_table *a, struct cdc_hash_table *b)
 Swaps hash_tables a and b. This operation is very fast and never fails. More...
 

Detailed Description

Function Documentation

◆ cdc_hash_table_clear()

void cdc_hash_table_clear ( struct cdc_hash_table t)

Removes all the elements from the hash_table.

Parameters
[in]t- cdc_hash_table

◆ cdc_hash_table_insert()

enum cdc_stat cdc_hash_table_insert ( struct cdc_hash_table t,
void *  key,
void *  value,
struct cdc_hash_table_iter it,
bool *  inserted 
)

Inserts an element into the container, if the container doesn't already contain an element with an equivalent key.

Parameters
[in]t- cdc_hash_table
[in]key- key of the element
[in]value- value of the element
[out]ret- pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool denoting whether the insertion took place. The pointer can be equal to NULL.
Returns
CDC_STATUS_OK in a successful case or other value indicating an error.

◆ cdc_hash_table_insert_or_assign()

enum cdc_stat cdc_hash_table_insert_or_assign ( struct cdc_hash_table t,
void *  key,
void *  value,
struct cdc_hash_table_iter it,
bool *  inserted 
)

Inserts an element or assigns to the current element if the key already exists.

Parameters
[in]t- cdc_hash_table
[in]key- key of the element
[in]value- value of the element
[out]ret- pair. The bool component is true if the insertion took place and false if the assignment took place. The iterator component is pointing at the element that was inserted or updated.
Returns
CDC_STATUS_OK in a successful case or other value indicating an error.

◆ cdc_hash_table_erase()

size_t cdc_hash_table_erase ( struct cdc_hash_table t,
void *  key 
)

Removes the element (if one exists) with the key equivalent to key.

Parameters
[in]t- cdc_hash_table
[in]key- key value of the elements to remove
Returns
number of elements removed.

◆ cdc_hash_table_swap()

void cdc_hash_table_swap ( struct cdc_hash_table a,
struct cdc_hash_table b 
)

Swaps hash_tables a and b. This operation is very fast and never fails.

Parameters
[in,out]a- cdc_hash_table
[in,out]b- cdc_hash_table