193 #include <kApi/Data/kMap.x.h>
247 obj->equalsFx =
function;
267 obj->hashFx =
function;
269 kCheck(xkMap_Rehash(map));
285 return obj->keyField.type;
299 return obj->valueField.type;
327 return obj->capacity;
353 #define kMap_FindT(kMap_map, KPtr_key, VPtr_value) \
354 xkMap_FindT(kMap_map, KPtr_key, VPtr_value, sizeof(*KPtr_key), sizeof(*VPtr_value))
380 #define kMap_HasT(kMap_map, KPtr_key) \
381 xkMap_HasT(kMap_map, KPtr_key, sizeof(*KPtr_key))
406 #define kMap_AddT(kMap_map, KPtr_key, VPtr_value) \
407 xkMap_AddT(kMap_map, KPtr_key, VPtr_value, sizeof(*KPtr_key), sizeof(*VPtr_value))
440 #define kMap_ReplaceT(kMap_map, KPtr_key, VPtr_value) \
441 xkMap_ReplaceT(kMap_map, KPtr_key, VPtr_value, sizeof(*KPtr_key), sizeof(*VPtr_value))
476 #define kMap_RemoveT(kMap_map, KPtr_key, KPtr_oldKey, VPtr_oldValue) \
477 xkMap_RemoveT(kMap_map, KPtr_key, KPtr_oldKey, VPtr_oldValue, sizeof(*KPtr_key), sizeof(*KPtr_oldKey), sizeof(*VPtr_oldValue))
509 #define kMap_DiscardT(kMap_map, KPtr_key) \
510 xkMap_DiscardT(kMap_map, KPtr_key, sizeof(*KPtr_key))
582 #define kMap_FindItemT(kMap_map, KPtr_key, kMapItemPtr_item) \
583 xkMap_FindItemT(kMap_map, KPtr_key, kMapItemPtr_item, sizeof(*KPtr_key))
622 #define kMap_KeyT(kMap_map, kMapItem_item, K) \
623 kCast(K*, xkMap_KeyT(kMap_map, kMapItem_item, sizeof(K)))
637 #define kMap_KeyAsT(kMap_map, kMapItem_item, K) \
638 kPointer_ReadAs(xkMap_KeyAsT(kMap_map, kMapItem_item, sizeof(K)), K)
667 #define kMap_ValueT(kMap_map, kMapItem_item, V) \
668 kCast(V*, xkMap_ValueT(kMap_map, kMapItem_item, sizeof(V)))
701 #define kMap_SetValueT(kMap_map, kMapItem_item, VPtr_value) \
702 xkMap_SetValueT(kMap_map, kMapItem_item, VPtr_value, sizeof(*VPtr_value))
717 #define kMap_SetValueAsT(kMap_map, kMapItem_item, V_value, V) \
718 (kPointer_WriteAs(xkMap_ValueAsT(kMap_map, kMapItem_item, sizeof(V)), V_value, V), (void)0)
732 #define kMap_ValueAsT(kMap_map, kMapItem_item, V) \
733 kPointer_ReadAs(xkMap_ValueAsT(kMap_map, kMapItem_item, sizeof(V)), V)
kStatus kMap_Purge(kMap map)
Disposes any elements in the map and sets the count of map items to zero.
kStatus kMap_Find(kMap map, const void *key, void *value)
Finds the value associated with the given key.
kStatus kMap_Clear(kMap map)
Sets the count of map items to zero.
kBool kSuccess(kStatus status)
Returns kTRUE if the given expression value is kOK.
Definition: kApiDef.h:546
kStatus kMap_SetEqualsFx(kMap map, kEqualsFx function)
Sets a custom key equality comparator.
Definition: kMap.h:243
kMapItem kMap_First(kMap map)
Gets a reference to the first map item (key-value pair).
Represents a void pointer.
kStatus kMap_Discard(kMap map, const void *key)
Removes a key-value pair from the map.
Definition: kMap.h:490
kSize kMap_Count(kMap map)
Returns the count of map elements.
Definition: kMap.h:309
kStatus kMap_Allocate(kMap map, kType keyType, kType valueType, kSize initialCapacity)
Reallocates the map.
kStatus kMap_SetHashFx(kMap map, kHashFx function)
Sets a custom hash code generator.
Definition: kMap.h:263
Represents an unsigned integer that can store a pointer address.
Abstract base class for memory allocator types.
void kValue_Import(kType type, void *value, const void *source)
Imports the content of another value into this value.
Definition: kValue.h:108
#define kCheck(EXPRESSION)
Executes a return statement if the given expression is not kOK.
Definition: kApiDef.h:559
kStatus kMap_Construct(kMap *map, kType keyType, kType valueType, kSize initialCapacity, kAlloc allocator)
Constructs a kMap object.
kStatus kMap_Reserve(kMap map, kSize capacity)
Ensures that capacity is reserved for at least the specified number of map items. ...
#define kInlineFx(TYPE)
Inline method declaration helper.
Definition: kApiDef.h:26
const void * kMap_Key(kMap map, kMapItem item)
Returns a pointer to the key associated with a map item.
Definition: kMap.h:603
kType kMap_ValueType(kMap map)
Returns the value type.
Definition: kMap.h:295
kSize(kCall * kHashFx)(const void *item)
Callback signature to determine hash code of an item.
Definition: kApiDef.h:1725
Represents a signed integer that can store a pointer address.
kSize kMap_Capacity(kMap map)
Returns the number of elements for which space has been allocated.
Definition: kMap.h:323
kStatus kMap_Add(kMap map, const void *key, const void *value)
Adds a new key-value pair.
kBool(kCall * kEqualsFx)(const void *item1, const void *item2)
Callback signature to determine equality of two items.
Definition: kApiDef.h:1717
#define kObj(TypeName_T, T_object)
Declares a local "obj" (this-pointer) variable and initializes it from a type-checked object handle...
Definition: kApiDef.h:2921
kPointer kMapItem
Represents a key-value pair within a map.
kBool kMap_Has(kMap map, const void *key)
Reports whether the specified key is present in the map.
Definition: kMap.h:364
kStatus kMap_FindItem(kMap map, const void *key, kMapItem *item)
Finds the map item associated with the given key.
kStatus kMap_Assign(kMap map, kMap source)
Performs a shallow copy of the source map.
Core Zen type declarations.
kType kMap_KeyType(kMap map)
Returns the key type.
Definition: kMap.h:281
void * kPointer_ByteOffset(const void *pointer, kSSize offset)
Calculates a pointer address from a base address and a byte offset.
Definition: kApiDef.h:278
kMapItem kMap_Next(kMap map, kMapItem item)
Given a map item, gets a reference to the next map item.
kStatus kMap_RemoveItem(kMap map, kMapItem item)
Removes an item from the map.
kStatus kMap_Replace(kMap map, const void *key, const void *value)
Adds or replaces a key-value pair.
kStatus kMap_Remove(kMap map, const void *key, void *oldKey, void *oldValue)
Removes a key-value pair from the map, optionally returning the old key and/or value.
kStatus kMap_SetValue(kMap map, kMapItem item, const void *value)
Sets the value associated with a map item.
Definition: kMap.h:679
Represents metadata about a type (class, interface, or value).
void * kMap_Value(kMap map, kMapItem item)
Returns a pointer to the value associated with a map item.
Definition: kMap.h:648
#define kOK
Operation successful.
Definition: kApiDef.h:513
Represents an error code.
#define kNULL
Null pointer.
Definition: kApiDef.h:267
Represents a boolean value.
Represents a collection of key-value pairs stored in a hash table.