|
libcmutils 0.6.5
Multi-platform C99 utility library
|
Dynamic array of any type element. More...
Data Fields | |
| CMBool(* | Add )(CMUTIL_Array *array, void *item, void **ret) |
| Add a new element to this array. | |
| void *(* | Remove )(CMUTIL_Array *array, const void *compval) |
| Remove an item from this array. | |
| void *(* | InsertAt )(CMUTIL_Array *array, void *item, uint32_t index) |
| Insert a new element to this array. | |
| void *(* | RemoveAt )(CMUTIL_Array *array, uint32_t index) |
| Remove an item from this array. | |
| void *(* | SetAt )(CMUTIL_Array *array, void *item, uint32_t index) |
| Replace an item at the position of this array. | |
| void *(* | GetAt )(const CMUTIL_Array *array, uint32_t index) |
| Get an item from this array. | |
| void *(* | Find )(const CMUTIL_Array *array, const void *compval, uint32_t *index) |
| Find an item from this array. | |
| size_t(* | GetSize )(const CMUTIL_Array *array) |
| The size of this array. | |
| CMBool(* | Push )(CMUTIL_Array *array, void *item) |
| Push an item to the end of this array like a stack operation. | |
| void *(* | Pop )(CMUTIL_Array *array) |
| Pop an item from the end of this array like a stack operation. | |
| void *(* | Top )(const CMUTIL_Array *array) |
| Get the top element from this array like a stack operation. | |
| void *(* | Bottom )(const CMUTIL_Array *array) |
| Get the bottom element from this array like a stack operation. | |
| CMUTIL_Iterator *(* | Iterator )(const CMUTIL_Array *array) |
| Get iterator of all items in this array. | |
| void(* | Clear )(CMUTIL_Array *array) |
| Clear this array object. | |
| void(* | Destroy )(CMUTIL_Array *array) |
| Destroy this array object. | |
Dynamic array of any type element.
| CMBool(* CMUTIL_Array::Add) (CMUTIL_Array *array, void *item, void **ret) |
Add a new element to this array.
If this array is a sorted array (created including comparator callback function), this method will add a new item to the appropriate location. Otherwise, this method will add a new item to the end of this array. If the freecb is supplied at the creation, this array will take the ownership of the item.
| array | This dynamic array object. |
| item | Item to be added. |
| ret | Pointer to store the previous data at that position if this array is a sorted array. NULL if this is not a sorted array. |
| void *(* CMUTIL_Array::Remove) (CMUTIL_Array *array, const void *compval) |
Remove an item from this array.
This method will work both this array is sorted or not. But if this array is sorted, more efficient binary search will be used, otherwise linear search will be used. The compval will be compared with array elements in a binary search manner if this array is sorted. If this array is not sorted, the memory address will be compared to search the item. The ownership of the item will be moved to caller.
| array | This dynamic array object. |
| compval | Search key of an item to be removed. |
| void *(* CMUTIL_Array::InsertAt) (CMUTIL_Array *array, void *item, uint32_t index) |
Insert a new element to this array.
This method will only work if this array is not a sorted array. New item will be stored at the given index. If the freecb is supplied at the creation, this array will take the ownership of the item.
| array | This dynamic array object. |
| item | Item to be inserted. |
| index | The index of this array where the item will be stored in. |
| void *(* CMUTIL_Array::RemoveAt) (CMUTIL_Array *array, uint32_t index) |
Remove an item from this array.
The item at the index of this array will be removed. The ownership of the item will be moved to caller.
| array | This dynamic array object. |
| index | The index of this array which item will be removed. |
| void *(* CMUTIL_Array::SetAt) (CMUTIL_Array *array, void *item, uint32_t index) |
Replace an item at the position of this array.
This method will only work if this array is not a sorted array. The item positioned at the index of this array will be replaced with the given item. If the freecb is supplied at the creation, this array will take the ownership of the item.
| array | This dynamic array object. |
| item | New item which will replace the old one. |
| index | The index of this array, the item in which will be replaced. |
| void *(* CMUTIL_Array::GetAt) (const CMUTIL_Array *array, uint32_t index) |
Get an item from this array.
Get an item which is stored at a given index. The ownership of the item does not be moved to the caller.
| array | This dynamic array object. |
| index | The index of this array, the item in which will be retreived. |
index of this array. NULL if the given index is out of bound. | void *(* CMUTIL_Array::Find) (const CMUTIL_Array *array, const void *compval, uint32_t *index) |
Find an item from this array.
This method will use binary search if this is a sorted array. Otherwise, linear search is used with memory address comparison. The ownership of the item does not be moved to the caller.
| array | This dynamic array object. |
| compval | Search key of item which to be found. |
| index | The index reference of the item which found with compval. Where the found item index will be stored in. |
| size_t(* CMUTIL_Array::GetSize) (const CMUTIL_Array *array) |
The size of this array.
| array | This dynamic array object. |
| CMBool(* CMUTIL_Array::Push) (CMUTIL_Array *array, void *item) |
Push an item to the end of this array like a stack operation.
This method will only work if this array is not a sorted array. This operation will add the given item at the end of this array. If the freecb is supplied at the creation, this array will take the ownership of the item.
| array | This dynamic array object. |
| item | A new item to be pushed to this array. |
| void *(* CMUTIL_Array::Pop) (CMUTIL_Array *array) |
Pop an item from the end of this array like a stack operation.
This operation will remove an item at the end of this array. The ownership of the item will be moved to the caller.
| array | This dynamic array object. |
| void *(* CMUTIL_Array::Top) (const CMUTIL_Array *array) |
Get the top element from this array like a stack operation.
Get the item at the end of this array. The ownership of the item does not be moved to the caller.
| array | This dynamic array object. |
| void *(* CMUTIL_Array::Bottom) (const CMUTIL_Array *array) |
Get the bottom element from this array like a stack operation.
Get the item at the beginning of this array. The ownership of the item does not be moved to the caller.
| array | This dynamic array object. |
| CMUTIL_Iterator *(* CMUTIL_Array::Iterator) (const CMUTIL_Array *array) |
Get iterator of all items in this array.
| array | This dynamic array object. |
CMUTIL_Iterator object of all items in this array. CMUTIL_Iterator | void(* CMUTIL_Array::Clear) (CMUTIL_Array *array) |
Clear this array object.
Clear all items in this array object and make its size to zero. If the freecb parameter is supplied at creation, this callback will be called to all items in this array.
| array | This dynamic array object. |
| void(* CMUTIL_Array::Destroy) (CMUTIL_Array *array) |
Destroy this array object.
Destroy this object and its internal allocations. If the freecb parameter is supplied at creation, this callback will be called to all items in this array.
| array | This dynamic array object. |