12 #ifndef ROC_CORE_HASHMAP_IMPL_H_
13 #define ROC_CORE_HASHMAP_IMPL_H_
97 size_t buckets_capacity_(
size_t n_buckets)
const;
99 bool realloc_buckets_(
size_t n_buckets);
100 void dealloc_buckets_();
102 bool member_of_bucket_array_(
Bucket* buckets,
111 void proceed_rehash_(
bool in_insert);
113 size_t get_next_bucket_size_(
size_t current_count);
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.
HashmapData * front() const
Get first node in hashmap.
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 * prevof(HashmapData *node) const
Get hashmap node previous to given one.
HashmapData * nextof(HashmapData *node) const
Get hashmap node next to given one.
bool(* key_equals_callback)(HashmapData *node, const void *key)
Callback function pointer type for key equality check.
HashmapData * back() const
Get last node in hashmap.
HashmapData * find_node(hashsum_t hash, const void *key, key_equals_callback callback) const
Find node in the hashmap.
void remove(HashmapData *node, bool skip_rehash)
Remove node from hashmap.
HashmapImpl(void *preallocated_data, size_t num_embedded_buckets, IArena &arena)
Initialize empty hashmap.
ROC_ATTR_NODISCARD bool grow()
Grow hashtable capacity.
bool contains(const HashmapData *node) const
Check if node belongs to hashmap.
~HashmapImpl()
Deinitialize.
size_t capacity() const
Get maximum number of nodes that can be added to hashmap before grow() should be called.
size_t hashsum_t
Hash type.
Commonly used types and functions.
Hashmap node internal data.
HashmapData * head
Pointer to head node.