|
libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
|
Go to the source code of this file.
Data Structures | |
| struct | GblArrayMapEntry |
| struct | GblArrayMap |
Macros | |
| #define | GBL_ARRAY_MAP_NPOS |
| #define | GBL_ARRAY_MAP_SIZE(elements) |
| #define | GBL_ARRAY_MAP_BINARY_SEARCH_CUTOFF_SIZE |
| #define | GBL_PSELF |
| #define | GBL_PCSELF |
Typedefs | |
| typedef GBL_RESULT(* | GblArrayMapDtorFn) (const GblArrayMap *, uintptr_t key, void *pEntry) |
| typedef int(* | GblArrayMapCmpFn) (const GblArrayMap *, uintptr_t key1, uintptr_t key2) |
GblArrayMap container and related functions
Dynamic array-based [K,V] pair associative container.
Contiguous array-based associative container with [K,V] pairs. GblArrayMap is essentially a flat map structure with a few specific properties:
Definition in file gimbal_array_map.h.
| #define GBL_ARRAY_MAP_NPOS |
Invalid index identifier returned when an entry couldn't be found.
Definition at line 19 of file gimbal_array_map.h.
| #define GBL_ARRAY_MAP_SIZE | ( | elements | ) |
Calculates total size of the GblArrayMap structure with elements.
Definition at line 20 of file gimbal_array_map.h.
| #define GBL_ARRAY_MAP_BINARY_SEARCH_CUTOFF_SIZE |
Magical break-even point for when binary searches out-perform linear searches, based on profiling.
Definition at line 21 of file gimbal_array_map.h.
| #define GBL_PSELF |
Definition at line 23 of file gimbal_array_map.h.
| #define GBL_PCSELF |
Definition at line 24 of file gimbal_array_map.h.
| typedef GBL_RESULT(* GblArrayMapDtorFn) (const GblArrayMap *, uintptr_t key, void *pEntry) |
Custom destructor type for userdata values.
Definition at line 31 of file gimbal_array_map.h.
| typedef int(* GblArrayMapCmpFn) (const GblArrayMap *, uintptr_t key1, uintptr_t key2) |
Custom comparator for nontrivial key types.
Definition at line 32 of file gimbal_array_map.h.
| GblArrayMap * GblArrayMap_create | ( | GblArrayMapCmpFn | pFnComparator, |
| GblBool | binarySearches, | ||
| GblContext * | pCtx ) |
Pre-creates a GblArrayMap with the given comparator, binary search config, and context.
| pFnComparator | |
| binarySearches | |
| pCtx |
| GBL_RESULT GblArrayMap_destroy | ( | GblArrayMap ** | ppSelf | ) |
| size_t GblArrayMap_size | ( | GblArrayMap *const * | ppSelf | ) |
Returns the number of entries within the given map.
| GblContext * GblArrayMap_context | ( | GblArrayMap *const * | ppSelf | ) |
Returns the context associated with the given map.
| GblBool GblArrayMap_empty | ( | GblArrayMap *const * | ppSelf | ) |
Returns whether the given map is empty.
| GblBool GblArrayMap_binarySearches | ( | GblArrayMap *const * | ppSelf | ) |
Returns whether the given map is sorted and uses binary searches.
| GblBool GblArrayMap_contains | ( | GblArrayMap *const * | ppSelf, |
| uintptr_t | key ) |
Returns true if the given map contains the given key.
| GblBool GblArrayMap_containsUserdata | ( | GblArrayMap *const * | ppSelf, |
| uintptr_t | key ) |
Returns true if the given map contains the given key, associated with a userdata value.
| GblBool GblArrayMap_containsVariant | ( | GblArrayMap *const * | ppSelf, |
| uintptr_t | key ) |
Returns true if the given map contains the given key, associated with a GblVariant value.
| uintptr_t GblArrayMap_getValue | ( | GblArrayMap *const * | ppSelf, |
| uintptr_t | key ) |
Returns the GblVariant or userdata value associated with the given key as a uintptr_t.
| GblVariant * GblArrayMap_getVariant | ( | GblArrayMap *const * | ppSelf, |
| uintptr_t | key ) |
Returns the GblVariant associated with the given key.
| uintptr_t GblArrayMap_atValue | ( | GblArrayMap *const * | ppSelf, |
| uintptr_t | key ) |
Returns the GblVariant or userdata value associated with the given key, erroring if not found.
| GblVariant * GblArrayMap_atVariant | ( | GblArrayMap *const * | ppSelf, |
| uintptr_t | key ) |
Returns the GblVariant associated with the given key, erroring if not found.
| GBL_RESULT GblArrayMap_setUserdata | ( | GblArrayMap ** | ppSelf, |
| uintptr_t | key, | ||
| uintptr_t | value, | ||
| GblArrayMapDtorFn | pDtor ) |
Inserts or replaces the entry with the given key with a userdata value and optional destructor.
| GBL_RESULT GblArrayMap_setVariant | ( | GblArrayMap ** | ppSelf, |
| uintptr_t | key, | ||
| GblVariant * | pVariant ) |
Inserts or replaces the entry with the given key with a GblVariant.
| size_t GblArrayMap_insertUserdata | ( | GblArrayMap ** | ppSelf, |
| uintptr_t | key, | ||
| uintptr_t | value, | ||
| GblArrayMapDtorFn | pDtor ) |
Attempts to insert a new entry with the given key and userdata, returning the insertion index.
| size_t GblArrayMap_insertVariant | ( | GblArrayMap ** | ppSelf, |
| uintptr_t | key, | ||
| GblVariant * | pVariant ) |
Attempts to insert a new entry with the given key and GblVariant value, returning insertion index.
| GblBool GblArrayMap_erase | ( | GblArrayMap ** | ppSelf, |
| uintptr_t | key ) |
Attempts to erase the value with the given key, returning GBL_FALSE if not found.
| ppSelf | |
| key |
| GblBool GblArrayMap_extractVariant | ( | GblArrayMap ** | ppSelf, |
| uintptr_t | key, | ||
| GblVariant * | pVariant ) |
Attempts to remove the GblVariant with the given key, moving it into the given pointer if found.
| ppSelf | |
| key | |
| pVariant |
| GblBool GblArrayMap_extractValue | ( | GblArrayMap ** | ppSelf, |
| uintptr_t | key, | ||
| uintptr_t * | pValue ) |
Attempts to remove the value with the given key, moving it into the given pointer if found.
| ppSelf | |
| key | |
| pValue |
| void GblArrayMap_clear | ( | GblArrayMap ** | ppSelf | ) |
Clears all entries within the given map.
| ppSelf |
| size_t GblArrayMap_find | ( | GblArrayMap *const * | ppSelf, |
| uintptr_t | key ) |
Returns the index of the entry with the given key.
| uintptr_t GblArrayMap_probeKey | ( | GblArrayMap *const * | ppSelf, |
| size_t | index ) |
Returns the key for the entry at the given index.
| uintptr_t GblArrayMap_probeValue | ( | GblArrayMap *const * | ppSelf, |
| size_t | index ) |
Returns the value for the entry at the given index.
| GblVariant * GblArrayMap_probeVariant | ( | GblArrayMap *const * | ppSelf, |
| size_t | index ) |
Returns the GblVariant for the entry at the given index.