|
Zen API
|
Represents a collection of key-value pairs stored in a hash table.
The kMap class represents a hash-table of key-value pairs. The kMap constructor accepts kType arguments that determine the key type and value type. The map will automatically grow as new items are inserted.
For maps that contain key or value objects (e.g. kString) as opposed to values (e.g. kText32), the objects are not automatically destroyed when the map is destroyed. To recursively destroy both the map and its keys/values, use kObject_Dispose.
kMap supports the kObject_Clone, kObject_Dispose, and kObject_Size methods.
kMap supports the kdat6 serialization protocol.

Public Member Functions | |
| kStatus | kMap_Add (kMap map, const void *key, const void *value) |
| Adds a new key-value pair. More... | |
| kStatus | kMap_Allocate (kMap map, kType keyType, kType valueType, kSize initialCapacity) |
| Reallocates the map. More... | |
| kStatus | kMap_Assign (kMap map, kMap source) |
| Performs a shallow copy of the source map. More... | |
| kSize | kMap_Capacity (kMap map) |
| Returns the number of elements for which space has been allocated. More... | |
| kStatus | kMap_Clear (kMap map) |
| Sets the count of map items to zero. More... | |
| kStatus | kMap_Construct (kMap *map, kType keyType, kType valueType, kSize initialCapacity, kAlloc allocator) |
| Constructs a kMap object. More... | |
| kSize | kMap_Count (kMap map) |
| Returns the count of map elements. More... | |
| kStatus | kMap_Find (kMap map, const void *key, void *value) |
| Finds the value associated with the given key. More... | |
| kStatus | kMap_FindItem (kMap map, const void *key, kMapItem *item) |
| Finds the map item associated with the given key. More... | |
| kMapItem | kMap_First (kMap map) |
| Gets a reference to the first map item (key-value pair). More... | |
| const void * | kMap_Key (kMap map, kMapItem item) |
| Returns a pointer to the key associated with a map item. More... | |
| kType | kMap_KeyType (kMap map) |
| Returns the key type. More... | |
| kMapItem | kMap_Next (kMap map, kMapItem item) |
| Given a map item, gets a reference to the next map item. More... | |
| kStatus | kMap_Purge (kMap map) |
| Disposes any elements in the map and sets the count of map items to zero. More... | |
| kStatus | kMap_Remove (kMap map, const void *key, void *oldKey, void *oldValue) |
| Removes a key-value pair from the map. More... | |
| kStatus | kMap_RemoveItem (kMap map, kMapItem item) |
| Removes an item from the map. More... | |
| kStatus | kMap_Replace (kMap map, const void *key, const void *value) |
| Adds or replaces a key-value pair. More... | |
| kStatus | kMap_Reserve (kMap map, kSize capacity) |
| Ensures that capacity is reserved for at least the specified number of map items. More... | |
| kStatus | kMap_SetEqualsFx (kMap map, kEqualsFx function) |
| Sets a custom key equality comparator. More... | |
| kSize | kMap_SetHashFx (kMap map, kHashFx function) |
| Sets a custom hash code generator. More... | |
| kStatus | kMap_SetValue (kMap map, kMapItem item, const void *value) |
| Sets the value associated with a map item. More... | |
| void * | kMap_Value (kMap map, kMapItem item) |
| Returns a pointer to the value associated with a map item. More... | |
| kType | kMap_ValueType (kMap map) |
| Returns the value type. More... | |
Public Member Functions inherited from kObject | |
| kAlloc | kObject_Alloc (kObject object) |
| Gets the memory allocator associated with this object. More... | |
| kStatus | kObject_Clone (kObject *object, kObject source, kAlloc allocator) |
| Constructs a new object by copying an existing object, including any aggregated child elements. More... | |
| kStatus | kObject_Destroy (kObject object) |
| Destroys the object. More... | |
| kStatus | kObject_Dispose (kObject object) |
| Destroys the object and any aggregated child elements. More... | |
| kBool | kObject_Equals (kObject object, kObject other) |
| Determines whether the object is equal to another object. More... | |
| kSize | kObject_HashCode (kObject object) |
| Gets a hash code representing the state of this object. More... | |
| kBool | kObject_Is (kObject object, kType type) |
| Determines whether this object is an instance of the specified type. More... | |
| kBool | kObject_IsShared (kObject object) |
| Reports whether the object is currently shared (reference count greater than one). More... | |
| kStatus | kObject_SetPool (kObject object, kObjectPool pool) |
| Sets the object pool associated with this object. More... | |
| kStatus | kObject_Share (kObject object) |
| Increments the reference count associated with this object. More... | |
| kSize | kObject_Size (kObject object) |
| Estimates the memory consumed by this object, including any aggregated child elements. More... | |
| kType | kObject_Type (kObject object) |
| Returns the type of the object. More... | |
Related | |
| kPointer | kMapItem |
| Represents a key-value pair within a map. | |
| #define | kMap_KeyType_(MAP) kxMap_KeyType_(MAP) |
| Macro version of kMap_KeyType. | |
| #define | kMap_ValueType_(MAP) kxMap_ValueType_(MAP) |
| Macro version of kMap_ValueType. | |
| #define | kMap_Count_(MAP) kxMap_Count_(MAP) |
| Macro version of kMap_Count. | |
| #define | kMap_KeyAs_(MAP, ITEM, TYPE) kxMap_KeyAs_(MAP, ITEM, TYPE) |
| Accesses a map item key and casts the key to the specified type. More... | |
| #define | kMap_ValueAs_(MAP, ITEM, TYPE) kxMap_ValueAs_(MAP, ITEM, TYPE) |
| Accesses a map item value and casts the value to the specified type. More... | |
Related inherited from kObject | |
| #define | kObject_Type_(OBJ) kxObject_Type_(OBJ) |
| Macro version of kObject_Type. | |
| #define | kObject_Is_(OBJ, TYPE) kxObject_Is_(OBJ, TYPE) |
| Macro version of kObject_Is. | |
| #define | kObject_Alloc_(OBJ) kxObject_Allocator_(OBJ) |
| Macro version of kObject_Alloc. | |