poser
A C framework for POsix SERvices
Loading...
Searching...
No Matches
PSC_List Class Reference

A list of objects. More...

#include <poser/core/list.h>

Public Member Functions

PSC_ListPSC_List_create (void)
 PSC_List default constructor.
 
size_t PSC_List_size (const PSC_List *self)
 Number of entries.
 
void * PSC_List_at (const PSC_List *self, size_t idx)
 Gets an object by position.
 
void PSC_List_append (PSC_List *self, void *obj, void(*deleter)(void *))
 Append an object to the list.
 
void PSC_List_remove (PSC_List *self, void *obj)
 Remove a given object from the list.
 
void PSC_List_removeAll (PSC_List *self, int(*matcher)(void *, const void *), const void *arg)
 Remove matching objects from the list.
 
PSC_ListIteratorPSC_List_iterator (const PSC_List *self)
 Creates an iterator for all entries.
 
void PSC_List_destroy (PSC_List *self)
 PSC_List destructor.
 
PSC_ListPSC_List_fromString (const char *str, const char *delim)
 Create a List of strings by splitting a given string.
 

Detailed Description

A list of objects.

Member Function Documentation

◆ PSC_List_append()

void PSC_List_append ( PSC_List self,
void *  obj,
void(*)(void *)  deleter 
)

Append an object to the list.

Parameters
selfthe PSC_List
objthe new object
deleteroptional function to destroy the object

◆ PSC_List_at()

void * PSC_List_at ( const PSC_List self,
size_t  idx 
)

Gets an object by position.

Parameters
selfthe PSC_List
idxposition of the object
Returns
the object stored at that position, or NULL

◆ PSC_List_create()

PSC_List * PSC_List_create ( void  )

PSC_List default constructor.

Creates a new PSC_List

Returns
a newly created PSC_List

◆ PSC_List_destroy()

void PSC_List_destroy ( PSC_List self)

PSC_List destructor.

All stored objects that have a deleter attached are destroyed as well.

Parameters
selfthe PSC_List

◆ PSC_List_fromString()

PSC_List * PSC_List_fromString ( const char *  str,
const char *  delim 
)

Create a List of strings by splitting a given string.

The string is split at any of the characters given in delim. Empty fields are ignored.

Parameters
strthe string to split
delimcharacters that are considered delimiting fields
Returns
a list of strings, or NULL if no non-empty fields were found

◆ PSC_List_iterator()

PSC_ListIterator * PSC_List_iterator ( const PSC_List self)

Creates an iterator for all entries.

The iterator contains a snapshot of all objects currently stored, modifications to the PSC_List will not be reflected in the iterator. In its initial state, the iterator points to an invalid position.

Parameters
selfthe PSC_List
Returns
an iterator

◆ PSC_List_remove()

void PSC_List_remove ( PSC_List self,
void *  obj 
)

Remove a given object from the list.

The object will not be automatically destroyed.

Parameters
selfthe PSC_List
objthe object to remove

◆ PSC_List_removeAll()

void PSC_List_removeAll ( PSC_List self,
int(*)(void *, const void *)  matcher,
const void *  arg 
)

Remove matching objects from the list.

Objects that are removed will be destroyed if they have a deleter attached.

Parameters
selfthe PSC_List
matcherfunction to compare each object to some specified value, must return 1 to have that object removed, 0 otherwise
argsome value for the matcher function to compare the objects against.

◆ PSC_List_size()

size_t PSC_List_size ( const PSC_List self)

Number of entries.

Parameters
selfthe PSC_List
Returns
the number of entries

The documentation for this class was generated from the following file: