12#ifndef ROC_CORE_HASHMAP_IMPL_H_
13#define ROC_CORE_HASHMAP_IMPL_H_
97 size_t buckets_capacity_(
size_t n_buckets)
const;
100 void dealloc_buckets_();
115 void* preallocated_data_;
116 size_t num_preallocated_buckets_;
119 size_t n_curr_buckets_;
122 size_t n_prev_buckets_;
127 size_t rehash_remain_nodes_;
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Intrusive hash table internal implementation.
bool insert(HashmapData *node, hashsum_t hash, const void *key, key_equals_callback callback)
Insert node into hashmap.
size_t size() const
Get number of nodes added to hashmap.
HashmapData * front() const
Get first node in hashmap.
HashmapData * back() const
Get last node in hashmap.
bool(* key_equals_callback)(HashmapData *node, const void *key)
Callback function pointer type for key equality check.
void remove(HashmapData *node, bool skip_rehash)
Remove node from hashmap.
HashmapData * prevof(HashmapData *node) const
Get hashmap node previous to given one.
HashmapImpl(void *preallocated_data, size_t num_embedded_buckets, IArena &arena)
Initialize empty hashmap.
bool grow()
Grow hashtable capacity.
bool contains(const HashmapData *node) const
Check if node belongs to hashmap.
~HashmapImpl()
Deinitialize.
HashmapData * nextof(HashmapData *node) const
Get hashmap node next to given one.
size_t capacity() const
Get maximum number of nodes that can be added to hashmap before grow() should be called.
HashmapData * find_node(hashsum_t hash, const void *key, key_equals_callback callback) const
Find node in the hashmap.
Shared ownership intrusive pointer.
Commonly used types and functions.
Hashmap node internal data.
HashmapData * head
Pointer to head node.