|
fht_table_t * | fht_init (uint32_t table_rows, uint32_t key_size, uint32_t data_size, uint32_t stash_size) |
| Function for initializing the hash table. More...
|
|
int | fht_insert (fht_table_t *table, const void *key, const void *data, void *key_lost, void *data_lost) |
| Function for inserting the item into the table without using stash. More...
|
|
int | fht_insert_wr (fht_table_t *table, const void *key, const void *data) |
| Function for inserting the item into the table without using stash and without replacing the oldest item when the row is full. More...
|
|
int | fht_insert_with_stash (fht_table_t *table, const void *key, const void *data, void *key_lost, void *data_lost) |
| Function for inserting the item into the table using stash. More...
|
|
int | fht_insert_with_stash_wr (fht_table_t *table, const void *key, const void *data) |
| Function for inserting the item into the table using stash and without replacing items in stash. More...
|
|
int | fht_remove (fht_table_t *table, const void *key) |
| Function for removing item from the table without looking for in stash. More...
|
|
int | fht_remove_locked (fht_table_t *table, const void *key, int8_t *lock_ptr) |
| Function for removing item from the table without looking for in stash. Function does not locks lock, it can be used only to remove item which is locked (after use of function fht_get_data_locked or fht_get_data_with_stash_locked). More...
|
|
int | fht_remove_with_stash (fht_table_t *table, const void *key) |
| Function for removing item from the table with looking for in stash. More...
|
|
int | fht_remove_with_stash_locked (fht_table_t *table, const void *key, int8_t *lock_ptr) |
| Function for removing item from the table with looking for in stash. Function does not locks lock, it can be used only to remove item which is locked (after use of function fht_get_data_locked or fht_get_data_with_stash_locked). More...
|
|
int | fht_remove_iter (fht_iter_t *iter) |
| Function for removing actual item from the table when using iterator. More...
|
|
void | fht_clear (fht_table_t *table) |
| Function for clearing the table. More...
|
|
void | fht_destroy (fht_table_t *table) |
| Function for destroying the table and freeing memory. More...
|
|
fht_iter_t * | fht_init_iter (fht_table_t *table) |
| Function for initializing iterator for the table. More...
|
|
void | fht_reinit_iter (fht_iter_t *iter) |
| Function for reinitializing iterator for the table. More...
|
|
int32_t | fht_get_next_iter (fht_iter_t *iter) |
| Function for getting next item in the table. More...
|
|
void | fht_destroy_iter (fht_iter_t *iter) |
| Function for destroying iterator and freeing memory. More...
|
|
Fast 4-way hash table with stash - header file.
- Author
- Matej Vido, xvido.nosp@m.m00@.nosp@m.stud..nosp@m.fit..nosp@m.vutbr.nosp@m..cz
- Date
- 2014
Definition in file fast_hash_table.h.
int fht_insert |
( |
fht_table_t * |
table, |
|
|
const void * |
key, |
|
|
const void * |
data, |
|
|
void * |
key_lost, |
|
|
void * |
data_lost |
|
) |
| |
Function for inserting the item into the table without using stash.
Function checks whether there already is item with the key "key" in the table. If not, function inserts the item in the table. Function checks whether there is free place in the current row. If yes, new item is inserted. If not, new item will replace the oldest item in row according to replacement vector. Function updates replacement vector and free flag.
key_lost and data_lost are set only when the return value is FHT_INSERT_LOST.
- Parameters
-
table | Pointer to the hash table structure. |
key | Pointer to key of the inserted item. |
data | Pointer to data of the inserted item. |
key_lost | Pointer to memory, where key of the replaced item will be inserted. If NULL, key of that item will be lost. |
data_lost | Pointer to memory, where data of the replaced item will be inserted. If NULL, data of that item will be lost. |
- Returns
- FHT_INSERT_OK if the item was successfully inserted. FHT_INSERT_LOST if the inserted item pulled out the oldest item in the row of the table. FHT_INSERT_FAILED if there already is an item with such key in the table.
int fht_insert_with_stash |
( |
fht_table_t * |
table, |
|
|
const void * |
key, |
|
|
const void * |
data, |
|
|
void * |
key_lost, |
|
|
void * |
data_lost |
|
) |
| |
Function for inserting the item into the table using stash.
Function checks whether there already is item with the key "key" in the table. If not, function inserts the item in the table. Function checks whether there is free place in the current row. If yes, new item is inserted. If not, new item will replace the oldest item in row according to replacement vector and the oldest item is inserted in stash. Function updates replacement vector and free flag.
- Parameters
-
table | Pointer to the hash table structure. |
key | Pointer to key of the inserted item. |
data | Pointer to data of the inserted item. |
key_lost | Pointer to memory, where key of the replaced item will be inserted. If NULL, key of that item will be lost. |
data_lost | Pointer to memory, where data of the replaced item will be inserted. If NULL, data of that item will be lost. |
key_lost and data_lost are set only when the return value is FHT_INSERT_LOST or FHT_INSERT_STASH_LOST.
- Returns
- FHT_INSERT_OK if the item was successfully inserted. FHT_INSERT_LOST if the inserted item pulled out the oldest item in the row of the table and it was not inserted in stash. FHT_INSERT_STASH_OK if the inserted item pulled out the oldest item in the row of the table and it was inserted in stash. FHT_INSERT_STASH_LOST if item inserted in stash replaced an item in stash. FHT_INSERT_FAILED if there already is an item with such key in the table.