|
cdsa
Arena allocators and friends
|
Data Structures | |
| struct | Set |
| Represents a set of unique keys. More... | |
| struct | SetItem |
| Represents a single item in a set. More... | |
Macros | |
| #define | set_for_each(item, self) |
| Iterate over all items in a set. | |
Functions | |
| static Set | set_create (Arena *arena) |
| Create a new set. | |
| static bool | set_insert (Set *self, const void *key, long size) |
| Insert a new item into a set. | |
| static bool | set_remove (Set *self, const void *key, long size) |
| Remove an item from a set. | |
| static bool | set_find (const Set *self, const void *key, long size) |
| Find an item of a set. | |
| static Set | set_clone (const Set *self, Arena *arena) |
| Create a clone of a set. | |
| static SetItem * | set_items (const Set *self, Arena *arena) |
| Retrieve an array of set items. | |
| static Set | set_union (const Set *self, const Set *other, Arena *arena) |
| Compute the union of two sets. | |
| static Set | set_intersection (const Set *self, const Set *other, Arena *arena) |
| Compute the intersection of two sets. | |
| static Set | set_difference (const Set *self, const Set *other, Arena *arena) |
| Compute the difference of two sets. | |
| static Set | set_symmetric_difference (const Set *self, const Set *other, Arena *arena) |
| Compute the symmetric difference of two sets. | |
| static bool | set_is_subset (const Set *self, const Set *other) |
| Check if one set is a subset of another. | |
| static bool | set_is_superset (const Set *self, const Set *other) |
| Check if one set is a superset of another. | |
Variables | |
| static constexpr long | set_hash_shift = 2 |
| Number of hash bits to shift out. | |
| static constexpr long | set_branch_select = 64 - set_hash_shift |
| Bit mask to select branch. | |
| #define set_for_each | ( | item, | |
| self | |||
| ) |
Iterate over all items in a set.
| item | Current set item |
| self | Pointer to a set |
Create a new set.
| arena | Pointer to an arena allocator |
|
static |
Insert a new item into a set.
| self | Pointer to a set |
| key | Pointer to the key data |
| size | Size of the key data in bytes (optional) |
true if the key is newly added, or false if it already exists size == 0, key is assumed to be a null-terminated string
|
static |
Remove an item from a set.
| self | Pointer to a set |
| key | Pointer to the key data |
| size | Size of the key data in bytes (optional) |
true if the key is successfully removed, or false if it is not found size == 0, key is assumed to be a null-terminated string
|
static |
Find an item of a set.
| self | Pointer to a set |
| key | Pointer to the key data |
| size | Size of the key data in bytes (optional) |
true if the key exists, or false if it is not found size == 0, key is assumed to be a null-terminated string Create a clone of a set.
| self | Pointer to a set |
| arena | Pointer to an arena allocator (optional) |
Retrieve an array of set items.
| self | Pointer to a set |
| arena | Pointer to an arena allocator (optional) |
Compute the union of two sets.
| self | Pointer to a set |
| other | Pointer to another set |
| arena | Pointer to an arena allocator (optional) |
Compute the intersection of two sets.
| self | Pointer to a set |
| other | Pointer to another set |
| arena | Pointer to an arena allocator (optional) |
Compute the difference of two sets.
| self | Pointer to a set |
| other | Pointer to another set |
| arena | Pointer to an arena allocator (optional) |
Compute the symmetric difference of two sets.
| self | Pointer to a set |
| other | Pointer to another set |
| arena | Pointer to an arena allocator (optional) |
Check if one set is a subset of another.
| self | Pointer to a set |
| other | Pointer to another set |
true if all items in the first set are also in the second, or false otherwise