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

Interface for a thread-safe, generic, singly linked list. More...

#include <IArray.h>

Public Attributes

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.

Detailed Description

Interface for a thread-safe, generic, singly linked list.

Member Data Documentation

◆ clear

void(* IArray::clear) (struct IArray *self, void(*callback)(void *item))

Clears all items from the list.

Parameters
selfPointer to the IArray instance.
callbackOptional 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
selfPointer to the IArray instance.
errorOut-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
selfPointer to the IArray instance.
itemPointer 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
selfPointer to the IArray instance.
predicateFunction that returns true for the desired element.
dataOptional 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
selfPointer to the IArray instance.
callbackFunction called for each item. Receives the element, data and out-param error.
dataOptional data passed to callback (e.g., notification).
errorOut-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
selfPointer 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
selfPointer to the IArray instance.
itemPointer to the item to append.
errorOut-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
selfPointer to the IArray instance.
itemPointer 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
selfPointer 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
selfPointer 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
selfPointer to the IArray instance.
itemPointer to the item to insert.
errorOut-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: