Interface for a generic key-value dictionary.
More...
#include <IDictionary.h>
|
const void *(* | get )(const struct IDictionary *self, const char *key) |
| Retrieves the value associated with the given key.
|
bool(* | put )(struct IDictionary *self, const char *key, const void *value) |
| Adds or updates a key-value pair in the dictionary.
|
bool(* | containsKey )(const struct IDictionary *self, const char *key) |
| Checks whether the dictionary contains a given key.
|
void *(* | removeItem )(struct IDictionary *self, const char *key) |
| Removes the key-value pair associated with the given key.
|
void *(* | replace )(const struct IDictionary *self, const char *key, const void *value) |
| Replaces the value associated with a key, returning the previous value.
|
void(* | clear )(const struct IDictionary *self, void(*callback)(void *value)) |
| Clears all key-value pairs from the dictionary.
|
Interface for a generic key-value dictionary.
Stores associations between string keys and arbitrary pointer values.
◆ clear
void(* IDictionary::clear) (const struct IDictionary *self, void(*callback)(void *value)) |
Clears all key-value pairs from the dictionary.
- Parameters
-
self | Pointer to the dictionary instance. |
callback | Optional function pointer called for each value before removal. May be NULL if no cleanup is needed. |
◆ containsKey
bool(* IDictionary::containsKey) (const struct IDictionary *self, const char *key) |
Checks whether the dictionary contains a given key.
- Parameters
-
self | Pointer to the dictionary instance. |
key | Null-terminated string key to check. |
- Returns
- true if the key exists; false otherwise.
◆ get
const void *(* IDictionary::get) (const struct IDictionary *self, const char *key) |
Retrieves the value associated with the given key.
- Parameters
-
self | Pointer to the dictionary instance. |
key | Null-terminated string key to look up. |
- Returns
- Pointer to the value if key exists; otherwise NULL.
◆ put
bool(* IDictionary::put) (struct IDictionary *self, const char *key, const void *value) |
Adds or updates a key-value pair in the dictionary.
- Parameters
-
self | Pointer to the dictionary instance. |
key | Null-terminated string key to add or update. |
value | Pointer to the value to associate with the key. |
- Returns
- true if insertion or update was successful; false on failure (e.g. memory allocation failure).
◆ removeItem
void *(* IDictionary::removeItem) (struct IDictionary *self, const char *key) |
Removes the key-value pair associated with the given key.
- Parameters
-
self | Pointer to the dictionary instance. |
key | Null-terminated string key to remove. |
- Returns
- Pointer to the removed value if the key was found; otherwise NULL. Caller is responsible for managing the memory of the returned value.
◆ replace
void *(* IDictionary::replace) (const struct IDictionary *self, const char *key, const void *value) |
Replaces the value associated with a key, returning the previous value.
- Parameters
-
self | Pointer to the dictionary instance. |
key | Null-terminated string key to update. |
value | New value pointer to associate with the key. |
- Returns
- Pointer to the old value if key was found; otherwise NULL. Caller is responsible for managing the memory of the returned value.
The documentation for this struct was generated from the following file: