CObject
CIList Struct Reference

Interface for list data structures. More...

#include <CIList.h>

+ Inheritance diagram for CIList:

Public Member Functions

CIListError CIList_Add (struct CIList *self, void *element)
 
CIListError CIList_AddAt (struct CIList *self, void *element, size_t index)
 
CIListError CIList_Get (struct CIList *self, void *element, size_t index)
 
CIListError CIList_Remove (struct CIList *self, void *element, size_t index)
 
void CIList_Clear (struct CIList *self)
 
size_t CIList_Size (struct CIList *self)
 
size_t CIList_MaxSize (struct CIList *self)
 

Data Fields

struct CInterface interface
 

Detailed Description

Provides an interface for adding/removing data from a list. This is a copy by value list, meaning all insert/get/remove functions will copy at the location pointed to by inputs. See function descriptions for more details.

Member Function Documentation

CIListError CIList_Add ( struct CIList self,
void *  element 
)

Add parameter element, by copy, to the first empty spot in the list. If there are no empty spots, the list will be resized or an error returned.

Parameters
selfThe list.
elementA pointer to the data which will be copied into the list.
Returns
  • CILIST_OK: The element was inserted into the list
  • CILIST_ERR_FULL: No room in the list, and if a resize was attempted it failed. the element wasn't added.
CIListError CIList_AddAt ( struct CIList self,
void *  element,
size_t  index 
)

Insert the element into the specefied index of the list. If there is already something at that index in the list, it gets overwritten.

Parameters
selfThe list.
elementPointer to the data that is copied into the list.
indexThe index in the list to copy the data.
Returns
  • CILIST_OK: Element was inserted.
  • CILIST_ERR_INDEX: Index out of bounds.
void CIList_Clear ( struct CIList self)

Reset the list to a completely empty state. All data within the list is lost.

Parameters
selfThe list.
CIListError CIList_Get ( struct CIList self,
void *  element,
size_t  index 
)

Get an element from the list at the specified index. The element is not removed from the list.

Parameters
selfThe list.
elementData will be copied from the list into the location pointed to by this. If a NULL pointer is provided, no data is copied.
indexThe location in the list to get an item from.
Returns
  • CILIST_OK: Retrieved the element.
  • CILIST_ERR_EMPTY: Nothing at the location given by parameter index.
  • CILIST_ERR_INDEX: The index is out of bounds, not a valid index.
size_t CIList_MaxSize ( struct CIList self)

Poll the currently maximum available space in the list.

Parameters
selfThe list.
Returns
The maximum available space in the list.
CIListError CIList_Remove ( struct CIList self,
void *  element,
size_t  index 
)

Remove an element from the list at the specified index.

Parameters
selfThe list.
elementPointer to location where data removed from the list will be copied into. If this is a NULL pointer, no data is copied.
indexIndex in the list to remove data.
Returns
  • CILIST_OK: Element removed from given index.
  • CILIST_ERR_EMPTY: No element at the given index.
  • CILIST_ERR_INDEX: Index is out of bounds.
size_t CIList_Size ( struct CIList self)

Poll the current size of the list.

Parameters
selfThe list.
Returns
Number of items currently in the list.

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