12 #ifndef ROC_CORE_HASHMAP_IMPL_H_
13 #define ROC_CORE_HASHMAP_IMPL_H_
95 size_t buckets_capacity_(
size_t n_buckets)
const;
97 bool realloc_buckets_(
size_t n_buckets);
98 void dealloc_buckets_();
100 bool member_of_bucket_array_(
Bucket* buckets,
109 void proceed_rehash_(
bool in_insert);
111 size_t get_next_bucket_size_(
size_t current_count);
113 void* preallocated_data_;
114 size_t num_preallocated_buckets_;
117 size_t n_curr_buckets_;
120 size_t n_prev_buckets_;
125 size_t rehash_remain_nodes_;
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Intrusive hash table internal implementation.
bool insert(HashmapNode::HashmapNodeData *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.
void remove(HashmapNode::HashmapNodeData *node, bool skip_rehash)
Remove node from hashmap.
HashmapNode::HashmapNodeData * nextof(HashmapNode::HashmapNodeData *node) const
Get hashmap node next to given one.
HashmapNode::HashmapNodeData * find_node(hashsum_t hash, const void *key, key_equals_callback callback) const
Find node in the 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 HashmapNode::HashmapNodeData *node) const
Check if node belongs to hashmap.
~HashmapImpl()
Deinitialize.
HashmapNode::HashmapNodeData * front() const
Get first node in hashmap.
HashmapNode::HashmapNodeData * back() const
Get last node in hashmap.
bool(* key_equals_callback)(HashmapNode::HashmapNodeData *node, const void *key)
Callback function pointer type for key equality check.
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.
HashmapNode::HashmapNodeData * head
Pointer to head node.