Collection
Loading...
Searching...
No Matches
IDictionary Struct Reference

Interface for a generic key-value dictionary. More...

#include <IDictionary.h>

Public Attributes

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.

Detailed Description

Interface for a generic key-value dictionary.

Stores associations between string keys and arbitrary pointer values.

Member Data Documentation

◆ clear

void(* IDictionary::clear) (const struct IDictionary *self, void(*callback)(void *value))

Clears all key-value pairs from the dictionary.

Parameters
selfPointer to the dictionary instance.
callbackOptional 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
selfPointer to the dictionary instance.
keyNull-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
selfPointer to the dictionary instance.
keyNull-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
selfPointer to the dictionary instance.
keyNull-terminated string key to add or update.
valuePointer 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
selfPointer to the dictionary instance.
keyNull-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
selfPointer to the dictionary instance.
keyNull-terminated string key to update.
valueNew 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: