|
| void | ht_init (struct hashtable *self, struct hashtable_vtabk *vtabk, struct hashtable_vtabv *vtabv, size_t capacity) |
| | IMPLEMENTATIONS.
|
| |
| void | ht_clone (struct hashtable *orig, struct hashtable *clone) |
| |
| void | ht_drop (struct hashtable *self) |
| |
| enum cvx_flags | ht_flag (struct hashtable *_self_) |
| |
| size_t | ht_count (struct hashtable *_self_) |
| |
| size_t | ht_capacity (struct hashtable *_self_) |
| |
| double | ht_load (struct hashtable *_self_) |
| |
| _Bool | ht_empty (struct hashtable *_self_) |
| |
| _Bool | ht_insert (struct hashtable *_self_, TKey _key_, TVal _val_) |
| |
| _Bool | ht_update (struct hashtable *_self_, TKey _key_, TVal _new_, TVal *_old_) |
| |
| _Bool | ht_remove (struct hashtable *_self_, TKey _key_, TVal *_out_) |
| |
| TVal | ht_get (struct hashtable *_self_, TKey _key_) |
| |
| TVal * | ht_get_ref (struct hashtable *_self_, TKey _key_) |
| |
| _Bool | ht_contains (struct hashtable *_self_, TKey _key_) |
| |
| struct hashtable_iter | ht_iter_init_start (struct hashtable *_target_) |
| | ITERATOR.
|
| |
| struct hashtable_iter | ht_iter_init_end (struct hashtable *_target_) |
| |
| struct hashtable_iter * | ht_iter_start (struct hashtable *_target_) |
| |
| struct hashtable_iter * | ht_iter_end (struct hashtable *_target_) |
| |
| void | ht_iter_drop (struct hashtable_iter *_iter_) |
| |
| _Bool | ht_iter_at_start (struct hashtable_iter *_iter_) |
| |
| _Bool | ht_iter_at_end (struct hashtable_iter *_iter_) |
| |
| size_t | ht_iter_count (struct hashtable_iter *_iter_) |
| |
| void | ht_iter_to_start (struct hashtable_iter *_iter_) |
| |
| void | ht_iter_to_end (struct hashtable_iter *_iter_) |
| |
| void | ht_iter_next (struct hashtable_iter *_iter_) |
| |
| void | ht_iter_prev (struct hashtable_iter *_iter_) |
| |
| void | ht_iter_forward (struct hashtable_iter *_iter_, size_t _steps_) |
| |
| void | ht_iter_backward (struct hashtable_iter *_iter_, size_t _steps_) |
| |
| TKey | ht_iter_key (struct hashtable_iter *_iter_) |
| |
| TVal | ht_iter_value (struct hashtable_iter *_iter_) |
| |
| size_t | ht_iter_index (struct hashtable_iter *_iter_) |
| |
| struct hashtable_entry * | ht__get_entry (struct hashtable *_self_, TKey _key_) |
| | PRIVATE FUNCTIONS.
|
| |
| size_t | ht__next_prime (size_t _required_) |
| |
| _Bool | ht__resize (struct hashtable *_self_, size_t _new_cap_) |
| |
| void | ht__iter_scan_bounds (struct hashtable *_target_, size_t *_first_, size_t *_last_) |
| |
| void | ht__proxy_clone (cvx_container *_orig_, cvx_container *_clone_) |
| | PROXIES.
|
| |
| void | ht__proxy_drop (cvx_container *_col_) |
| |
| size_t | ht__proxy_count (cvx_container *_col_) |
| |
| size_t | ht__proxy_capacity (cvx_container *_col_) |
| |
| _Bool | ht__proxy_empty (cvx_container *_col_) |
| |
| _Bool | ht__proxy_insert (cvx_container *_col_, TKey _key_, TVal _val_) |
| |
| _Bool | ht__proxy_update (cvx_container *_col_, TKey _key_, TVal _new_, TVal *_old_) |
| |
| _Bool | ht__proxy_remove (cvx_container *_col_, TKey _key_, TVal *_out_) |
| |
| TVal | ht__proxy_get (cvx_container *_col_, TKey _key_) |
| |
| _Bool | ht__proxy_contains (cvx_container *_col_, TKey _key_) |
| |
| cvx_container * | ht__proxy_iter_start (cvx_container *_col_) |
| |
| cvx_container * | ht__proxy_iter_end (cvx_container *_col_) |
| |
| void | ht__proxy_iter_drop (cvx_container *_col_) |
| |
| _Bool | ht__proxy_iter_at_start (cvx_container *_col_) |
| |
| _Bool | ht__proxy_iter_at_end (cvx_container *_col_) |
| |
| size_t | ht__proxy_iter_count (cvx_container *_col_) |
| |
| void | ht__proxy_iter_to_start (cvx_container *_col_) |
| |
| void | ht__proxy_iter_to_end (cvx_container *_col_) |
| |
| void | ht__proxy_iter_next (cvx_container *_col_) |
| |
| void | ht__proxy_iter_prev (cvx_container *_col_) |
| |
| void | ht__proxy_iter_forward (cvx_container *_col_, size_t _steps_) |
| |
| void | ht__proxy_iter_backward (cvx_container *_col_, size_t _steps_) |
| |
| TKey | ht__proxy_iter_key (cvx_container *_col_) |
| |
| TVal | ht__proxy_iter_value (cvx_container *_col_) |
| |
| size_t | ht__proxy_iter_index (cvx_container *_col_) |
| |
A configurable hashtable that maps K -> V.
- Author
- Leonardo Vencovsky
- Version
- 0.0.1
Required Macros
- K: Type name of keys in the map.
- V: Type name of values in the map.
- SNAME: Prefix of all declared structs (e.g.
struct SNAME, struct SNAME_vtabv, etc.).
- PFX: Prefix of all functions, including implementation detail ones.
- TAG: A unique integer tag that identifies this data structure.
Implementation
Open-addressing, linear-probing hashtable with robin hood insertion.
Keys are hashed with vtabk->hash and compared with vtabk->comp. Both are required; vtabk->clone / vtabk->drop and vtabv->clone / vtabv->drop are optional.
Capacity is always a prime number. A resize is triggered whenever count >= capacity * load (default load = 0.7). Deletions use tombstones, which are purged on resize.
TO-DOs
- Implement OPTs, so the hashtable can be customized with linear-probing or separate chaining.