Tinyhash
This is a library containing multiple C implementations of hashmap.
|
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include "../common/iterator.h"
#include "../common/types.h"
#include "entry.h"
Go to the source code of this file.
Classes | |
struct | th_sc_table_t |
Represent a separate chaining table. More... | |
Functions | |
void | th_sc_table_init (th_sc_table_t *table) |
Initialize a separate chaining table. | |
th_generic_table_t | th_sc_table_create () |
Return an allocated separate chaining table. | |
th_any_t | th_sc_table_get (th_generic_table_t table, th_any_t data, size_t data_size) |
Get a value from an separate chaining table. Return NULL if it does exist. | |
bool | th_sc_table_put (th_generic_table_t table, th_any_t data, size_t data_size, th_any_t value) |
Insert a value within an separate chaining table. Return true on success. | |
void | th_sc_table_free (th_generic_table_t table) |
Free an separate chaining table. | |
bool | th_sc_table_delete (th_generic_table_t table, th_any_t data, size_t data_size) |
Delete a key value pair in an separate chaining table. Return true on success. | |
th_iterator_t * | th_sc_iterator_begin (th_generic_table_t generic_table, bool is_begin) |
Return a new iterator. | |
int | th_sc_table_len (th_generic_table_t generic_table) |
Returns the table length. | |
th_iterator_t * th_sc_iterator_begin | ( | th_generic_table_t | generic_table, |
bool | is_begin ) |
Return a new iterator.
If is_begin
is true, it will initialize the iterator with the first element. Otherwise, it will be empty.
generic_table | |
is_begin |
Definition at line 287 of file table.c.
References th_iterator_s::index, th_iterator_create(), and th_sc_iterator_next().
th_generic_table_t th_sc_table_create | ( | ) |
Return an allocated separate chaining table.
Definition at line 36 of file table.c.
References _th_sc_table_create().
bool th_sc_table_delete | ( | th_generic_table_t | table, |
th_any_t | data, | ||
size_t | data_size ) |
Delete a key value pair in an separate chaining table. Return true on success.
table | |
data | |
data_size |
Definition at line 191 of file table.c.
References th_sc_table_t::capacity, th_sc_table_t::count, th_sc_table_t::entries, th_key_t::hash, th_sc_entry_s::key, th_sc_entry_s::next, th_sc_entry_s::previous, th_key_create(), and th_sc_table_find().
void th_sc_table_free | ( | th_generic_table_t | table | ) |
Free an separate chaining table.
table |
Definition at line 222 of file table.c.
References th_sc_table_t::capacity, th_sc_table_t::entries, th_sc_entry_s::next, and th_sc_table_init().
Referenced by th_sc_table_increase().
th_any_t th_sc_table_get | ( | th_generic_table_t | table, |
th_any_t | data, | ||
size_t | data_size ) |
Get a value from an separate chaining table. Return NULL if it does exist.
table | |
data | |
data_size |
Definition at line 133 of file table.c.
References th_key_create(), th_sc_table_find(), and th_sc_entry_s::value.
void th_sc_table_init | ( | th_sc_table_t * | table | ) |
Initialize a separate chaining table.
table |
Definition at line 13 of file table.c.
References th_sc_table_t::capacity, th_sc_table_t::count, and th_sc_table_t::entries.
Referenced by _th_sc_table_create(), th_sc_table_free(), and th_sc_table_increase().
int th_sc_table_len | ( | th_generic_table_t | generic_table | ) |
bool th_sc_table_put | ( | th_generic_table_t | table, |
th_any_t | data, | ||
size_t | data_size, | ||
th_any_t | value ) |
Insert a value within an separate chaining table. Return true on success.
table | |
data | |
data_size | |
value |
Definition at line 183 of file table.c.
References th_key_create(), and th_sc_table_put_with_key().