libircbot
library providing a framework for implementing an IRC bot
Loading...
Searching...
No Matches
IBList Class Reference

A list of objects. More...

#include <ircbot/list.h>

Public Member Functions

IBListIBList_create (void)
 IBList default constructor. More...
 
size_t IBList_size (const IBList *self)
 Number of entries. More...
 
void * IBList_at (const IBList *self, size_t idx)
 Gets an object by position. More...
 
void IBList_append (IBList *self, void *obj, void(*deleter)(void *))
 Append an object to the list. More...
 
void IBList_remove (IBList *self, void *obj)
 Remove a given object from the list. More...
 
void IBList_removeAll (IBList *self, int(*matcher)(void *, const void *), const void *arg)
 Remove matching objects from the list. More...
 
IBListIteratorIBList_iterator (const IBList *self)
 Creates an iterator for all entries. More...
 
void IBList_destroy (IBList *self)
 IBList destructor. More...
 
IBListIBList_fromString (const char *str, const char *delim)
 Create a List of strings by splitting a given string. More...
 

Detailed Description

A list of objects.

Member Function Documentation

◆ IBList_append()

void IBList_append ( IBList self,
void *  obj,
void(*)(void *)  deleter 
)

Append an object to the list.

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

◆ IBList_at()

void * IBList_at ( const IBList self,
size_t  idx 
)

Gets an object by position.

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

◆ IBList_create()

IBList * IBList_create ( void  )

IBList default constructor.

Creates a new IBList

Returns
a newly created IBList

◆ IBList_destroy()

void IBList_destroy ( IBList self)

IBList destructor.

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

Parameters
selfthe IBList

◆ IBList_fromString()

IBList * IBList_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

◆ IBList_iterator()

IBListIterator * IBList_iterator ( const IBList self)

Creates an iterator for all entries.

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

Parameters
selfthe IBList
Returns
an iterator

◆ IBList_remove()

void IBList_remove ( IBList self,
void *  obj 
)

Remove a given object from the list.

The object will not be automatically destroyed.

Parameters
selfthe IBList
objthe object to remove

◆ IBList_removeAll()

void IBList_removeAll ( IBList 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 IBList
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.

◆ IBList_size()

size_t IBList_size ( const IBList self)

Number of entries.

Parameters
selfthe IBList
Returns
the number of entries

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