|
const struct CCArrayList_VTable * | CCArrayList_GetVTable () |
|
CError | CCArrayList (struct CCArrayList *self, size_t element_size, size_t max_size) |
|
CError | CCArrayListStatic (struct CCArrayList *self, size_t element_size, size_t max_size, void *memory) |
|
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) |
|
- See also
- CCListIterator
Implements a non resizable, copy by value, list using an array as the underlying data structure. Below is an example code showing adding items to a list which can hold chars, and has a length of 3.
unsigned char test_val = 0;
++test_val;
++test_val;
printf("test val at index 0 is %d", test_val);
printf("test val at index 1 is %d", test_val);
printf("test val at index 2 is %d", test_val);
CDestroy(&list);
Valid indices into the array list are [0, 1, ..., n-1] where n is the length of the list.
Since this is a copy by value list, all inputs to the list point to the memory location where data will be copied from/to.
In the above example, the list was created to copy only one byte (the size of an unsigned char). When adding/removing elements, the address of the char was provided, because the input points to the memory location which will be copied from/to.
- Attention
- To call inherited methods from CIList, use as input to first argument:
CError CCArrayListStatic |
( |
struct CCArrayList * |
self, |
|
|
size_t |
element_size, |
|
|
size_t |
max_size, |
|
|
void * |
memory |
|
) |
| |
- Class Constructor
Creates an array list using the memory block provided as input. The size
of the memory block for different element_size and max_size lists can be resolved at compile time using the macro CCARRAY_LIST_SIZE(). For example, to make a list with the max size of three elements, and each element being the size of an int:
char list_memory[CCARRAY_LIST_SIZE(sizeof(int), 3)];
Also, take a look at CCArrayList().
- Parameters
-
self | The list. |
element_size | The size of elements being copied into/out of the list. |
max_size | The maximum number of elements in the list. |
- Returns
- Always returns COBJ_OK.