Structure which can store lists of objects.
More...
|
#define | ci_vector_get(vector, i) (i < vector->count ? (const void *)vector->items[i]: (const void *)NULL) |
| Return a pointer to the i item of the vector.
|
|
|
typedef struct ci_vector | ci_vector_t |
| The ci_vector_t objects can store a list of objects. More...
|
|
Structure which can store lists of objects.
The ci_vector_t objects can store a list of objects.
Currently can grow up to a fixed size.
void* ci_vector_add |
( |
ci_vector_t * |
vector, |
|
|
const void * |
obj, |
|
|
size_t |
size |
|
) |
| |
Add an item to the vector.
- Parameters
-
vector | a pointer to the ci_vector_t object |
obj | pointer to the object to add in vector |
size | the size of the new item. |
- Returns
- a pointer to the new item on success, NULL otherwise
Allocate the required memory and initialize a ci_vector_t object.
- Parameters
-
max_size | the maximum memory to use |
- Returns
- the allocated object on success, or NULL on failure
Destroy an ci_vector_t object.
- Parameters
-
vector | a pointer to ci_vector_t object to be destroyed |
void ci_vector_iterate |
( |
const ci_vector_t * |
vector, |
|
|
void * |
data, |
|
|
int(*)(void *data, const void *) |
fn |
|
) |
| |
Run the given function for each vector item.
- Parameters
-
vector | a pointer to the ci_vector_t object |
data | a pointer to data which will be passed to the fn function |
fn | a pointer to the function which will be run for each vector item. The iteration will stop if the fn function return non zero value. |
Delete the last element of a vector.
- Parameters
-
vector | a pointer to the ci_vector_t object |
- Returns
- a pointer to the popped vector item on success, NULL otherwise