339#define cxMapPut(map, key, value) cx_map_put(map, CX_HASH_KEY(key), value)
378#define cxMapEmplace(map, key) cx_map_emplace(map, CX_HASH_KEY(key))
407#define cxMapGet(map, key) cx_map_get(map, CX_HASH_KEY(key))
418#define cxMapContains(map, key) (cxMapGet(map, key) != NULL)
451#define cxMapRemove(map, key) cx_map_remove(map, CX_HASH_KEY(key), NULL)
473#define cxMapRemoveAndGet(map, key, targetbuf) cx_map_remove(map, CX_HASH_KEY(key), targetbuf)
void *(* cx_clone_func)(void *target, const void *source, const CxAllocator *allocator, void *data)
Function pointer type for clone functions.
Definition allocator.h:141
struct cx_allocator_s CxAllocator
High-Level type alias for the allocator type.
Definition allocator.h:80
Common definitions for various collection implementations.
#define CX_COLLECTION_BASE
Use this macro to declare common members for a collection structure.
Definition collection.h:118
Common definitions and feature checks.
#define CX_EXPORT
Only used for building Windows DLLs.
Definition common.h:289
#define CX_NONNULL
All pointer arguments must be non-NULL.
Definition common.h:141
#define CX_NODISCARD
Warn about discarded return value.
Definition common.h:256
#define CX_NONNULL_ARG(...)
The specified pointer arguments must be non-NULL.
Definition common.h:146
#define CX_EXTERN
Declares a function with external linkage.
Definition common.h:297
Interface for map implementations.
struct cx_hash_key_s CxHashKey
Type for a hash key.
Definition hash_key.h:61
#define CX_ITERATOR_BASE
Declares base attributes for an iterator.
Definition iterator.h:94
struct cx_list_s CxList
Common type for all list implementations.
Definition list.h:179
int cx_map_put(CxMap *map, CxHashKey key, void *value)
Puts a key/value-pair into the map.
int cxMapClone(CxMap *dst, const CxMap *src, cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data)
Performs a deep clone of one map into another.
CxMapIterator cxMapIterator(const CxMap *map)
Creates an iterator for a map.
int cxMapCloneShallow(CxMap *dst, const CxMap *src)
Performs a shallow clone of one map into another.
int cxMapUnion(CxMap *dst, const CxMap *src, cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data)
Clones entries into a map if their key does not exist yet.
cx_map_iterator_type
The type of iterator for a map.
Definition map.h:88
@ CX_MAP_ITERATOR_KEYS
Iterates over keys only.
Definition map.h:96
@ CX_MAP_ITERATOR_PAIRS
Iterates over key/value pairs.
Definition map.h:92
@ CX_MAP_ITERATOR_VALUES
Iterates over values only.
Definition map.h:100
int cx_map_remove(CxMap *map, CxHashKey key, void *targetbuf)
Removes a key/value-pair from the map by using the key.
struct cx_map_iterator_s CxMapIterator
Type for a map iterator.
Definition map.h:56
int cxMapListDifferenceShallow(CxMap *dst, const CxMap *src, const CxList *keys)
Clones entries of a map if their key is not present in a list.
int cxMapIntersection(CxMap *dst, const CxMap *src, const CxMap *other, cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data)
Clones entries of a map only if their key is present in another map.
struct cx_map_entry_s CxMapEntry
Type for a map entry.
Definition map.h:53
struct cx_map_class_s cx_map_class
Type for map class definitions.
Definition map.h:59
int cxMapListIntersectionShallow(CxMap *dst, const CxMap *src, const CxList *keys)
Clones entries of a map only if their key is present in a list.
int cxMapListDifference(CxMap *dst, const CxMap *src, const CxList *keys, cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data)
Clones entries of a map if their key is not present in a list.
void cxMapFree(CxMap *map)
Deallocates the memory of the specified map.
int cxMapDifference(CxMap *dst, const CxMap *minuend, const CxMap *subtrahend, cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data)
Clones entries of a map if their key is not present in another map.
int cxMapDifferenceShallow(CxMap *dst, const CxMap *minuend, const CxMap *subtrahend)
Clones entries of a map if their key is not present in another map.
int cxMapIntersectionShallow(CxMap *dst, const CxMap *src, const CxMap *other)
Clones entries of a map only if their key is present in another map.
void * cx_map_emplace(CxMap *map, CxHashKey key)
Allocates memory for a value in the map associated with the specified key.
struct cx_map_s CxMap
Type for the UCX map.
Definition map.h:50
int cxMapCompare(const CxMap *map, const CxMap *other)
Compares the entries of two maps.
int cxMapUnionShallow(CxMap *dst, const CxMap *src)
Clones entries into a map if their key does not exist yet.
int cxMapListIntersection(CxMap *dst, const CxMap *src, const CxList *keys, cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data)
Clones entries of a map only if their key is present in a list.
CxMapIterator cxMapIteratorValues(const CxMap *map)
Creates a value iterator for a map.
void cxMapClear(CxMap *map)
Clears a map by removing all elements.
CxMapIterator cxMapIteratorKeys(const CxMap *map)
Creates a key iterator for a map.
CxMap *const cxEmptyMap
A shared instance of an empty map.
size_t cxMapSize(const CxMap *map)
Returns the number of elements in this map.
void * cx_map_get(const CxMap *map, CxHashKey key)
Retrieves a value by using a key.
Strings that know their length.
Structure for holding the base data of a list.
Definition list.h:50
The class definition for arbitrary maps.
Definition map.h:167
void(* deallocate)(struct cx_map_s *map)
Deallocates the entire memory.
Definition map.h:171
int(* remove)(CxMap *map, CxHashKey key, void *targetbuf)
Removes an element.
Definition map.h:201
void(* clear)(struct cx_map_s *map)
Removes all elements.
Definition map.h:176
CxMapIterator(* iterator)(const CxMap *map, enum cx_map_iterator_type type)
Creates an iterator for this map.
Definition map.h:206
CxMapEntry(* put)(CxMap *map, CxHashKey key, void *value)
Add or overwrite an element.
Definition map.h:184
A map entry.
Definition map.h:74
const CxHashKey * key
A pointer to the key.
Definition map.h:78
void * value
A pointer to the value.
Definition map.h:82
Internal iterator struct - use CxMapIterator.
Definition map.h:106
size_t slot
Field for storing the current slot number.
Definition map.h:137
CxMapEntry entry
Reserved memory for a map entry.
Definition map.h:130
size_t index
Counts the elements successfully.
Definition map.h:143
size_t elem_count
May contain the total number of elements, if known.
Definition map.h:156
void * elem
Handle for the current element.
Definition map.h:122
size_t elem_size
The size of a value stored in this map.
Definition map.h:148
enum cx_map_iterator_type type
The type of this iterator.
Definition map.h:161
CxMap * map
Handle for the source map.
Definition map.h:115
Structure for the UCX map.
Definition map.h:62
cx_map_class * cl
The map class definition.
Definition map.h:68