ucx
UAP Common Extensions
|
Interface for list implementations. More...
Go to the source code of this file.
Data Structures | |
struct | cx_list_s |
Structure for holding the base data of a list. More... | |
struct | cx_list_class_s |
The class definition for arbitrary lists. More... | |
Typedefs | |
typedef struct cx_list_class_s | cx_list_class |
List class type. | |
typedef struct cx_list_s | CxList |
Common type for all list implementations. | |
Functions | |
void | cxListStoreObjects (CxList *list) |
Advises the list to store copies of the objects (default mode of operation). | |
void | cxListStorePointers (CxList *list) |
Advises the list to only store pointers to the objects. | |
static bool | cxListIsStoringPointers (CxList const *list) |
Returns true, if this list is storing pointers instead of the actual data. | |
static size_t | cxListSize (CxList const *list) |
Returns the number of elements currently stored in the list. | |
static int | cxListAdd (CxList *list, void const *elem) |
Adds an item to the end of the list. | |
static size_t | cxListAddArray (CxList *list, void const *array, size_t n) |
Adds multiple items to the end of the list. | |
static int | cxListInsert (CxList *list, size_t index, void const *elem) |
Inserts an item at the specified index. | |
static size_t | cxListInsertArray (CxList *list, size_t index, void const *array, size_t n) |
Inserts multiple items to the list at the specified index. | |
static int | cxListInsertAfter (CxMutIterator *iter, void const *elem) |
Inserts an element after the current location of the specified iterator. | |
static int | cxListInsertBefore (CxMutIterator *iter, void const *elem) |
Inserts an element before the current location of the specified iterator. | |
static int | cxListRemove (CxList *list, size_t index) |
Removes the element at the specified index. | |
static void | cxListClear (CxList *list) |
Removes all elements from this list. | |
static int | cxListSwap (CxList *list, size_t i, size_t j) |
Swaps two items in the list. | |
static void * | cxListAt (CxList *list, size_t index) |
Returns a pointer to the element at the specified index. | |
static CxIterator | cxListIteratorAt (CxList const *list, size_t index) |
Returns an iterator pointing to the item at the specified index. | |
static CxIterator | cxListBackwardsIteratorAt (CxList const *list, size_t index) |
Returns a backwards iterator pointing to the item at the specified index. | |
CxMutIterator | cxListMutIteratorAt (CxList *list, size_t index) |
Returns a mutating iterator pointing to the item at the specified index. | |
CxMutIterator | cxListMutBackwardsIteratorAt (CxList *list, size_t index) |
Returns a mutating backwards iterator pointing to the item at the specified index. | |
static CxIterator | cxListIterator (CxList const *list) |
Returns an iterator pointing to the first item of the list. | |
static CxMutIterator | cxListMutIterator (CxList *list) |
Returns a mutating iterator pointing to the first item of the list. | |
static CxIterator | cxListBackwardsIterator (CxList const *list) |
Returns a backwards iterator pointing to the last item of the list. | |
static CxMutIterator | cxListMutBackwardsIterator (CxList *list) |
Returns a mutating backwards iterator pointing to the last item of the list. | |
static ssize_t | cxListFind (CxList const *list, void const *elem) |
Returns the index of the first element that equals elem . | |
static void | cxListSort (CxList *list) |
Sorts the list in-place. | |
static void | cxListReverse (CxList *list) |
Reverses the order of the items. | |
int | cxListCompare (CxList const *list, CxList const *other) |
Compares a list to another list of the same type. | |
void | cxListDestroy (CxList *list) |
Deallocates the memory of the specified list structure. | |
Variables | |
CxList *const | cxEmptyList |
A shared instance of an empty list. | |
Interface for list implementations.
|
inlinestatic |
Adds an item to the end of the list.
list | the list |
elem | a pointer to the element to add |
|
inlinestatic |
Adds multiple items to the end of the list.
This method is more efficient than invoking cxListAdd() multiple times.
If there is not enough memory to add all elements, the returned value is less than n
.
If this list is storing pointers instead of objects array
is expected to be an array of pointers.
list | the list |
array | a pointer to the elements to add |
n | the number of elements to add |
|
inlinestatic |
Returns a pointer to the element at the specified index.
list | the list |
index | the index of the element |
NULL
if the index is out of bounds
|
inlinestatic |
Returns a backwards iterator pointing to the last item of the list.
The returned iterator is position-aware.
If the list is empty, a past-the-end iterator will be returned.
list | the list |
|
inlinestatic |
Returns a backwards iterator pointing to the item at the specified index.
The returned iterator is position-aware.
If the index is out of range, a past-the-end iterator will be returned.
list | the list |
index | the index where the iterator shall point at |
|
inlinestatic |
Removes all elements from this list.
If an element destructor function is specified, it is called for each element before removing them.
list | the list |
Compares a list to another list of the same type.
First, the list sizes are compared. If they match, the lists are compared element-wise.
list | the list |
other | the list to compare to |
void cxListDestroy | ( | CxList * | list | ) |
Deallocates the memory of the specified list structure.
Also calls content a destructor function, depending on the configuration in CxList.content_destructor_type.
This function itself is a destructor function for the CxList.
list | the list which shall be destroyed |
|
inlinestatic |
Returns the index of the first element that equals elem
.
Determining equality is performed by the list's comparator function.
list | the list |
elem | the element to find |
|
inlinestatic |
Inserts an item at the specified index.
If index
equals the list size
, this is effectively cxListAdd().
list | the list |
index | the index the element shall have |
elem | a pointer to the element to add |
|
inlinestatic |
Inserts an element after the current location of the specified iterator.
The used iterator remains operational, but all other active iterators should be considered invalidated.
If iter
is not a list iterator, the behavior is undefined. If iter
is a past-the-end iterator, the new element gets appended to the list.
iter | an iterator |
elem | the element to insert |
|
inlinestatic |
Inserts multiple items to the list at the specified index.
If index
equals the list size, this is effectively cxListAddArray().
This method is usually more efficient than invoking cxListInsert() multiple times.
If there is not enough memory to add all elements, the returned value is less than n
.
If this list is storing pointers instead of objects array
is expected to be an array of pointers.
list | the list |
index | the index where to add the elements |
array | a pointer to the elements to add |
n | the number of elements to add |
|
inlinestatic |
Inserts an element before the current location of the specified iterator.
The used iterator remains operational, but all other active iterators should be considered invalidated.
If iter
is not a list iterator, the behavior is undefined. If iter
is a past-the-end iterator, the new element gets appended to the list.
iter | an iterator |
elem | the element to insert |
|
inlinestatic |
Returns true, if this list is storing pointers instead of the actual data.
list |
|
inlinestatic |
Returns an iterator pointing to the first item of the list.
The returned iterator is position-aware.
If the list is empty, a past-the-end iterator will be returned.
list | the list |
|
inlinestatic |
Returns an iterator pointing to the item at the specified index.
The returned iterator is position-aware.
If the index is out of range, a past-the-end iterator will be returned.
list | the list |
index | the index where the iterator shall point at |
|
inlinestatic |
Returns a mutating backwards iterator pointing to the last item of the list.
The returned iterator is position-aware.
If the list is empty, a past-the-end iterator will be returned.
list | the list |
CxMutIterator cxListMutBackwardsIteratorAt | ( | CxList * | list, |
size_t | index | ||
) |
Returns a mutating backwards iterator pointing to the item at the specified index.
The returned iterator is position-aware.
If the index is out of range, a past-the-end iterator will be returned.
list | the list |
index | the index where the iterator shall point at |
|
inlinestatic |
Returns a mutating iterator pointing to the first item of the list.
The returned iterator is position-aware.
If the list is empty, a past-the-end iterator will be returned.
list | the list |
CxMutIterator cxListMutIteratorAt | ( | CxList * | list, |
size_t | index | ||
) |
Returns a mutating iterator pointing to the item at the specified index.
The returned iterator is position-aware.
If the index is out of range, a past-the-end iterator will be returned.
list | the list |
index | the index where the iterator shall point at |
|
inlinestatic |
Removes the element at the specified index.
If an element destructor function is specified, it is called before removing the element.
list | the list |
index | the index of the element |
|
inlinestatic |
Reverses the order of the items.
list | the list |
|
inlinestatic |
Returns the number of elements currently stored in the list.
list | the list |
|
inlinestatic |
Sorts the list in-place.
list | the list |
void cxListStoreObjects | ( | CxList * | list | ) |
Advises the list to store copies of the objects (default mode of operation).
Retrieving objects from this list will yield pointers to the copies stored within this list.
list | the list |
void cxListStorePointers | ( | CxList * | list | ) |
Advises the list to only store pointers to the objects.
Retrieving objects from this list will yield the original pointers stored.
list | the list |
|
inlinestatic |
Swaps two items in the list.
Implementations should only allocate temporary memory for the swap, if it is necessary.
list | the list |
i | the index of the first element |
j | the index of the second element |
|
extern |
A shared instance of an empty list.
Writing to that list is undefined.