cdcontainers
0.1.1
Library of data containers and collections for C programming language.
|
The cdc_hash_table is a struct and functions that provide a hash table. More...
#include <cdcontainers/common.h>
#include <cdcontainers/hash.h>
#include <cdcontainers/status.h>
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
Go to the source code of this file.
Data Structures | |
struct | cdc_hash_table_entry |
The cdc_hash_table_entry struct. More... | |
struct | cdc_hash_table |
The cdc_hash_table is service struct. More... | |
struct | cdc_hash_table_iter |
The cdc_hash_table_iter is service struct. More... | |
Functions | |
enum cdc_stat | cdc_hash_table_ctor (struct cdc_hash_table **t, struct cdc_data_info *info) |
Constructs an empty hash table. More... | |
enum cdc_stat | cdc_hash_table_ctorl (struct cdc_hash_table **t, struct cdc_data_info *info,...) |
Constructs a hash table, initialized by an variable number of pointers on cdc_pair's(first - key, and the second - value). The last item must be CDC_END. More... | |
enum cdc_stat | cdc_hash_table_ctorv (struct cdc_hash_table **t, struct cdc_data_info *info, va_list args) |
Constructs a hash table, initialized by args. The last item must be CDC_END. More... | |
enum cdc_stat | cdc_hash_table_ctor1 (struct cdc_hash_table **t, struct cdc_data_info *info, float load_factor) |
Constructs an empty hash table. More... | |
enum cdc_stat | cdc_hash_table_ctorl1 (struct cdc_hash_table **t, struct cdc_data_info *info, float load_factor,...) |
Constructs a hash table, initialized by an variable number of pointers on cdc_pair's(first - key, and the second - value). The last item must be CDC_END. More... | |
enum cdc_stat | cdc_hash_table_ctorv1 (struct cdc_hash_table **t, struct cdc_data_info *info, float load_factor, va_list args) |
Constructs a hash table, initialized by args. The last item must be CDC_END. More... | |
void | cdc_hash_table_dtor (struct cdc_hash_table *t) |
Destroys the hash table. More... | |
enum cdc_stat | cdc_hash_table_get (struct cdc_hash_table *t, void *key, void **value) |
Returns a value that is mapped to a key. If the key does not exist, then NULL will return. More... | |
size_t | cdc_hash_table_count (struct cdc_hash_table *t, void *key) |
Returns the number of elements with key that compares equal to the specified argument key, which is either 1 or 0 since this container does not allow duplicates. More... | |
void | cdc_hash_table_find (struct cdc_hash_table *t, void *key, struct cdc_hash_table_iter *it) |
Finds an element with key equivalent to key. More... | |
static size_t | cdc_hash_table_size (struct cdc_hash_table *t) |
Returns the number of items in the hash_table. More... | |
static bool | cdc_hash_table_empty (struct cdc_hash_table *t) |
Checks if the hash table has no elements. More... | |
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... | |
static void | cdc_hash_table_begin (struct cdc_hash_table *t, struct cdc_hash_table_iter *it) |
Initializes the iterator to the beginning. More... | |
static void | cdc_hash_table_end (struct cdc_hash_table *t, struct cdc_hash_table_iter *it) |
Initializes the iterator to the end. More... | |
static float | cdc_hash_table_load_factor (struct cdc_hash_table *t) |
Returns average number of elements per bucket. More... | |
static float | cdc_hash_table_max_load_factor (struct cdc_hash_table *t) |
Returns current maximum load factor. More... | |
static void | cdc_hash_table_set_max_load_factor (struct cdc_hash_table *t, float load_factor) |
Sets the maximum load factor. More... | |
enum cdc_stat | cdc_hash_table_rehash (struct cdc_hash_table *t, size_t count) |
Reserves at least the specified number of buckets. This regenerates the hash table. More... | |
enum cdc_stat | cdc_hash_table_reserve (struct cdc_hash_table *t, size_t count) |
Reserves space for at least the specified number of elements. This regenerates the hash table. More... | |
static size_t | cdc_hash_table_bucket_count (struct cdc_hash_table *t) |
Returns the number of buckets. More... | |
static void | cdc_hash_table_iter_next (struct cdc_hash_table_iter *it) |
Advances the iterator to the next element in the hash table. More... | |
static bool | cdc_hash_table_iter_has_next (struct cdc_hash_table_iter *it) |
Returns true if there is at least one element ahead of the iterator, i.e. the iterator is not at the back of the container; otherwise returns false. More... | |
static void * | cdc_hash_table_iter_key (struct cdc_hash_table_iter *it) |
Returns an item's key. More... | |
static void * | cdc_hash_table_iter_value (struct cdc_hash_table_iter *it) |
Returns an item's value. More... | |
static struct cdc_pair | cdc_hash_table_iter_key_value (struct cdc_hash_table_iter *it) |
Returns a pair, where first - key, second - value. More... | |
static bool | cdc_hash_table_iter_is_eq (struct cdc_hash_table_iter *it1, struct cdc_hash_table_iter *it2) |
Returns false if the iterator |it1| equal to the iterator |it2|, otherwise returns false. More... | |
The cdc_hash_table is a struct and functions that provide a hash table.