|
cdsa
Arena allocators and friends
|
Data Structures | |
| struct | Dict |
| Represents a dictionary of key-data pairs. More... | |
| struct | DictItem |
| Represents a single item of a dict. More... | |
Macros | |
| #define | dict_for_each(item, self) |
| Iterate over all items of a dict. | |
Typedefs | |
| typedef void * | DictDataCopy(Arena *, void *, const void *, long) |
| Data copy function. | |
Functions | |
| static Dict | dict_create (Arena *arena, long size) |
| Create a new dict. | |
| static void * | dict_insert (Dict *self, const void *key, long size, void *data) |
| Insert a new item into a dict. | |
| static void * | dict_remove (Dict *self, const void *key, long size) |
| Remove an item from a dict. | |
| static void * | dict_find (const Dict *self, const void *key, long size) |
| Find an item of a dict. | |
| static Dict | dict_clone (const Dict *self, Arena *arena) |
| Create a clone of a dict. | |
| static DictItem * | dict_items (const Dict *self, Arena *arena) |
| Retrieve an array of dict items. | |
Variables | |
| static constexpr long | dict_hash_shift = 2 |
| Number of hash bits to shift out. | |
| static constexpr long | dict_branch_select = 64 - dict_hash_shift |
| Bit mask to select branch. | |
| #define dict_for_each | ( | item, | |
| self | |||
| ) |
Iterate over all items of a dict.
| item | Current dict item |
| self | Pointer to a dict |
Create a new dict.
| arena | Pointer to an arena allocator |
| size | Size of item data in bytes (optional) |
size == 0, the data pointers will be directly assigned rather than copied
|
static |
Insert a new item into a dict.
| self | Pointer to a dict |
| key | Pointer to the key data |
| size | Size of the key data in bytes (optional) |
| data | Pointer to the item data |
nullptr if it is a new key size == 0, key is assumed to be a null-terminated string
|
static |
Remove an item from a dict.
| self | Pointer to a dict |
| key | Pointer to the key data |
| size | Size of the key data in bytes (optional) |
nullptr if the key is not found size == 0, key is assumed to be a null-terminated string
|
static |
Find an item of a dict.
| self | Pointer to a dict |
| key | Pointer to the key data |
| size | Size of the key data in bytes (optional) |
nullptr if the key is not found size == 0, key is assumed to be a null-terminated string Create a clone of a dict.
| self | Pointer to a dict |
| arena | Pointer to an arena allocator (optional) |