cbase 1.50.0
C/C++ Static Template
Loading...
Searching...
No Matches
base_map.h
Go to the documentation of this file.
1
54
55#ifndef BASE_MAP_H
56#define BASE_MAP_H
57
58#include "base_macros.h"
59#include "base_strings.h"
60#include "base_types.h"
62
64
70
79
87typedef struct BaseMapNode BaseMapNode;
93
100typedef struct BaseMap BaseMap;
105
123
136base_map_create(MemAllocator *alloc, usize bucket_count);
137
152base_map_insert(MemAllocator *alloc, BaseMap *map, String8 key, void *val);
153
161void *
163
175b32
177
185
197
217
229u64
231 // end base_map
233
235
236#endif // BASE_MAP_H
Context detection, compiler abstractions, utility macros, and data structures.
Sized UTF-8 string slices (String8) and manipulation utilities.
Core fixed-width type aliases and memory size constants.
BaseMapIter base_map_iter_begin(BaseMap *map)
Initializes an iterator positioned before the first entry.
BaseMapNode * base_map_iter_next(BaseMapIter *it)
Advances the iterator and returns the next live node.
String8 base_map_intern(MemAllocator *alloc, BaseMap *map, String8 str)
Interns a string, returning a stable canonical copy.
BaseMapInsertResult
Result returned by base_map_insert() indicating whether the key was new or already present.
Definition base_map.h:75
u64 base_hash_str8(String8 str)
Hashes a String8 using the FNV-1a (64-bit) algorithm.
BaseMap base_map_create(MemAllocator *alloc, usize bucket_count)
Creates and returns an initialized BaseMap.
b32 base_map_unlink(BaseMap *map, String8 key)
Logically removes a key by unlinking its node from the bucket chain.
void * base_map_lookup(BaseMap *map, String8 key)
Looks up a value by key.
BaseMapInsertResult base_map_insert(MemAllocator *alloc, BaseMap *map, String8 key, void *val)
Inserts or updates a key-value pair.
@ BASE_MAP_UPDATED
Definition base_map.h:77
@ BASE_MAP_INSERTED
Definition base_map.h:76
uint64_t u64
Definition base_types.h:49
#define C_LINKAGE_END
Closes a C linkage block for C++ compilers (Empty in C).
#define C_LINKAGE_BEGIN
Opens a C linkage block for C++ compilers (Empty in C).
size_t usize
Definition base_types.h:68
int32_t b32
Definition base_types.h:111
Generic interface for abstracting memory allocators.
BaseMapNode ** buckets
Definition base_map.h:102
usize bucket_count
Definition base_map.h:103
Iterator for walking all live entries in a map.
Definition base_map.h:118
usize bucket_idx
Definition base_map.h:120
BaseMap * map
Definition base_map.h:119
BaseMapNode * node
Definition base_map.h:121
void * val
Definition base_map.h:91
BaseMapNode * next
Definition base_map.h:89
String8 key
Definition base_map.h:90
An abstract allocator interface.
A sized UTF-8 string slice.