|
cbase 1.50.0
C/C++ Static Template
|
Arena-backed hash map keyed by String8, with string interning support. More...
#include "base_macros.h"#include "base_strings.h"#include "base_types.h"#include "memory/mem_allocator.h"
Go to the source code of this file.
Classes | |
| struct | BaseMapNode |
| struct | BaseMap |
| struct | BaseMapIter |
| Iterator for walking all live entries in a map. More... | |
Typedefs | |
| typedef enum BaseMapInsertResult | BaseMapInsertResult |
| Result returned by base_map_insert() indicating whether the key was new or already present. | |
| typedef struct BaseMapNode | BaseMapNode |
| A single key-value node in a bucket chain. | |
| typedef struct BaseMap | BaseMap |
| An arena-backed hash map with a fixed bucket array. | |
| typedef struct BaseMapIter | BaseMapIter |
| Iterator for walking all live entries in a map. | |
Enumerations | |
| enum | BaseMapInsertResult { BASE_MAP_INSERTED = 0 , BASE_MAP_UPDATED = 1 } |
| Result returned by base_map_insert() indicating whether the key was new or already present. More... | |
Functions | |
| BaseMap | base_map_create (MemAllocator *alloc, usize bucket_count) |
| Creates and returns an initialized BaseMap. | |
| BaseMapInsertResult | base_map_insert (MemAllocator *alloc, BaseMap *map, String8 key, void *val) |
| Inserts or updates a key-value pair. | |
| void * | base_map_lookup (BaseMap *map, String8 key) |
| Looks up a value by key. | |
| b32 | base_map_unlink (BaseMap *map, String8 key) |
| Logically removes a key by unlinking its node from the bucket chain. | |
| 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. | |
| u64 | base_hash_str8 (String8 str) |
| Hashes a String8 using the FNV-1a (64-bit) algorithm. | |
Arena-backed hash map keyed by String8, with string interning support.
Implements a hash map using separate chaining (linked list per bucket). Designed specifically for arena allocators - nodes are bump-allocated and never individually freed. The bucket array is fixed at creation time.
This design is optimal for:
Definition in file base_map.h.