Interface for a thread-safe, generic, singly linked list.
More...
#include <IArray.h>
|
| const void *(* | get )(const struct IArray *self, const int n) |
| void(* | forEach )(const struct IArray *self, void(*callback)(const void *element, const void *data, const char **error), const void *data, const char **error) |
| | Iterates over each item in the list.
|
| const void *(* | find )(const struct IArray *self, bool(*predicate)(const void *element, const void *data), const void *data) |
| | Finds the first element in the array that matches the given predicate.
|
| const void *(* | unshift )(struct IArray *self, const void *item, const char **error) |
| | Inserts an item at the beginning of the list.
|
| const void *(* | push )(struct IArray *self, const void *item, const char **error) |
| | Appends an item at the end of the list.
|
| bool(* | containsValue )(const struct IArray *self, const void *item) |
| | Checks if the list contains a specific item.
|
| const void *(* | shift )(struct IArray *self) |
| | Removes and returns the first item in the list.
|
| const void *(* | pop )(struct IArray *self) |
| | Removes and returns the last item in the list.
|
| void *(* | removeItem )(struct IArray *self, const void *item) |
| | Removes and returns a specific item from the list.
|
| struct IArray *(* | clone )(const struct IArray *self, const char **error) |
| | Clones the list (shallow copy).
|
| int(* | size )(const struct IArray *self) |
| | Returns the number of items in the list.
|
| void(* | clear )(struct IArray *self, void(*callback)(void *item)) |
| | Clears all items from the list.
|
Interface for a thread-safe, generic, singly linked list.
◆ clear
| void(* IArray::clear) (struct IArray *self, void(*callback)(void *item)) |
Clears all items from the list.
- Parameters
-
| self | Pointer to the IArray instance. |
| callback | Optional callback called on each item before it is freed. Can be NULL. |
◆ clone
| struct IArray *(* IArray::clone) (const struct IArray *self, const char **error) |
Clones the list (shallow copy).
- Parameters
-
| self | Pointer to the IArray instance. |
| error | Out-param for a static error string on failure (NULL on success). |
- Returns
- A new IArray instance that is a shallow copy of the original, or NULL on failure.
◆ containsValue
| bool(* IArray::containsValue) (const struct IArray *self, const void *item) |
Checks if the list contains a specific item.
- Parameters
-
| self | Pointer to the IArray instance. |
| item | Pointer to the item to search for. |
- Returns
- true if the item exists in the list, false otherwise.
◆ find
| const void *(* IArray::find) (const struct IArray *self, bool(*predicate)(const void *element, const void *data), const void *data) |
Finds the first element in the array that matches the given predicate.
- Parameters
-
| self | Pointer to the IArray instance. |
| predicate | Function that returns true for the desired element. |
| data | Optional user data passed to the predicate function. |
- Returns
- Pointer to the first matching element, or NULL if no match is found.
◆ forEach
| void(* IArray::forEach) (const struct IArray *self, void(*callback)(const void *element, const void *data, const char **error), const void *data, const char **error) |
Iterates over each item in the list.
- Parameters
-
| self | Pointer to the IArray instance. |
| callback | Function called for each item. Receives the element, data and out-param error. |
| data | Optional data passed to callback (e.g., notification). |
| error | Out-param for a static error string on failure (NULL on success). |
◆ get
| const void *(* IArray::get) (const struct IArray *self, const int n) |
◆ pop
| const void *(* IArray::pop) (struct IArray *self) |
Removes and returns the last item in the list.
- Parameters
-
| self | Pointer to the IArray instance. |
- Returns
- The removed item pointer, or NULL if list is empty.
◆ push
| const void *(* IArray::push) (struct IArray *self, const void *item, const char **error) |
Appends an item at the end of the list.
- Parameters
-
| self | Pointer to the IArray instance. |
| item | Pointer to the item to append. |
| error | Out-param for a static error string on failure (NULL on success). |
- Returns
- The appended item pointer on success, or NULL on failure.
◆ removeItem
| void *(* IArray::removeItem) (struct IArray *self, const void *item) |
Removes and returns a specific item from the list.
- Parameters
-
| self | Pointer to the IArray instance. |
| item | Pointer to the item to remove. |
- Returns
- The removed item pointer, or NULL if not found.
◆ shift
| const void *(* IArray::shift) (struct IArray *self) |
Removes and returns the first item in the list.
- Parameters
-
| self | Pointer to the IArray instance. |
- Returns
- The removed item pointer, or NULL if list is empty.
◆ size
| int(* IArray::size) (const struct IArray *self) |
Returns the number of items in the list.
- Parameters
-
| self | Pointer to the IArray instance. |
- Returns
- Number of items in the list.
◆ unshift
| const void *(* IArray::unshift) (struct IArray *self, const void *item, const char **error) |
Inserts an item at the beginning of the list.
- Parameters
-
| self | Pointer to the IArray instance. |
| item | Pointer to the item to insert. |
| error | Out-param for a static error string on failure (NULL on success). |
- Returns
- The inserted item pointer on success, or NULL on failure.
The documentation for this struct was generated from the following file: