Vector interface. More...
#include <sofia-sip/su_alloc.h>
Go to the source code of this file.
Defines | |
#define | SU_VECTOR_H |
Defined when <sofia-sip/su_vector.h> has been included. | |
Functions | |
su_vector_t * | su_vector_create (su_home_t *home, su_free_func_t free_f)) |
Create a vector. | |
void | su_vector_destroy (su_vector_t *) |
Destroy a vector. | |
int | su_vector_insert (su_vector_t *vector, usize_t index, void *item) |
Insert an item to vector. | |
int | su_vector_remove (su_vector_t *vector, usize_t index) |
Remove an item from vector. | |
int | su_vector_append (su_vector_t *, void *item) |
Append a item to vector. | |
void * | su_vector_item (su_vector_t const *, usize_t i) |
Get a numbered item from vector. | |
usize_t | su_vector_len (su_vector_t const *l) |
Get number of items in vector. | |
int | su_vector_empty (su_vector_t *vector) |
Remove all items from vector. | |
void ** | su_vector_get_array (su_vector_t *)) |
Get an array of pointers from the vector. | |
void | su_vector_free_array (su_vector_t *, void *array[]) |
Free the array. |
Vector interface.
#define SU_VECTOR_H |
Defined when <sofia-sip/su_vector.h> has been included.
int su_vector_append | ( | su_vector_t * | vector, | |
void * | item | |||
) |
Append a item to vector.
Append a item to vector.
The function su_vector_append() appends an item to the vector.
vector | pointer to a vector object | |
item | item to be appended |
0 | if successful | |
-1 | upon an error |
su_vector_t* su_vector_create | ( | su_home_t * | home, | |
su_free_func_t | free_func | |||
) |
Create a vector.
The function su_vector_create() creates a pointer vector object. The vector is initially empty. The function clones a memory home for the vector object from home. If a free_func is provided then that will be used to free the individual nodes (NULL if not used).
void su_vector_destroy | ( | su_vector_t * | vector | ) |
Destroy a vector.
The function su_vector_destroy() destroys a vector and frees all its nodes if a freeing function is available
int su_vector_empty | ( | su_vector_t * | vector | ) |
Remove all items from vector.
The function su_vector_empty() removes all items from the vector.
vector | pointer to a vector object |
0 | if successful | |
-1 | upon an error |
void** su_vector_get_array | ( | su_vector_t * | vector | ) |
Get an array of pointers from the vector.
Get an array of pointers from the vector.
The function su_vector_get_array() returns an array of pointer. The length of the array is always one longer than the length of the vector, and the last item in the returned array is always NULL.
vector | pointer to a vector object |
int su_vector_insert | ( | su_vector_t * | vector, | |
usize_t | index, | |||
void * | item | |||
) |
Insert an item to vector.
The function su_vector_insert() inserts an item to the vector. The items after the index will be moved further within the vector.
vector | pointer to a vector object | |
item | item to be appended | |
index | index for the new item |
0 | when successful | |
-1 | upon an error |
void* su_vector_item | ( | su_vector_t const * | vector, | |
usize_t | i | |||
) |
Get a numbered item from vector.
Get a numbered item from vector.
The function su_vector_item() returns a numbered item from vector. The numbering starts from 0.
vector | pointer to a vector object | |
i | index |
usize_t su_vector_len | ( | su_vector_t const * | l | ) |
Get number of items in vector.
Get number of items in vector.
The function su_vector_len() returns the number of items in the vector.
int su_vector_remove | ( | su_vector_t * | vector, | |
usize_t | index | |||
) |
Remove an item from vector.
The function su_vector_remove() removes an item from the vector. The items after the index will be moved backwards within the vector.
vector | pointer to a vector object | |
index | index for the removed item |
0 | when successful | |
-1 | upon an error |