libuproc
1.2.0
|
List of homogenous items (also known as "vector" or "arraylist") More...
Data Structures | |
struct | uproc_list |
List of homogenous items (also known as "vector" or "arraylist") More... | |
Macros | |
#define | uproc_list_get_all(list, buf, sz) uproc_list_get_all_safe((list), (buf), (sz), sizeof *(buf)) |
Get all items. More... | |
#define | uproc_list_set(list, index, value) uproc_list_set_safe((list), (index), (value), sizeof *(value)) |
Set item at index. More... | |
#define | uproc_list_append(list, value) uproc_list_append_safe((list), (value), sizeof *(value)) |
Append item to list. More... | |
#define | uproc_list_extend(list, values, n) uproc_list_extend_safe((list), (values), (n), sizeof *(values)) |
Append array of items. More... | |
#define | uproc_list_pop(list, value) uproc_list_pop_safe((list), (value), sizeof *(value)) |
Get and remove the last item. More... | |
Functions | |
uproc_list * | uproc_list_create (size_t value_size) |
Create an empty list. More... | |
void | uproc_list_destroy (uproc_list *list) |
Destroy list object. More... | |
void | uproc_list_clear (uproc_list *list) |
Remove all items. More... | |
int | uproc_list_add (uproc_list *list, const uproc_list *src) |
Append all elements of another list. More... | |
long | uproc_list_size (const uproc_list *list) |
Returns the number of items. More... | |
void | uproc_list_map (const uproc_list *list, void(*func)(void *, void *), void *opaque) |
Apply function to all items. More... | |
List of homogenous items (also known as "vector" or "arraylist")
#define uproc_list_get_all | ( | list, | |
buf, | |||
sz | |||
) | uproc_list_get_all_safe((list), (buf), (sz), sizeof *(buf)) |
Get all items.
Copies the whole list data, but at most sz
bytes, into the array pointed to by dest
. NOTE: buf
WILL BE EVALUATED TWICE.
list | list to copy from |
buf | buffer to copy into |
sz | size of dest in bytes |
sz
. #define uproc_list_set | ( | list, | |
index, | |||
value | |||
) | uproc_list_set_safe((list), (index), (value), sizeof *(value)) |
Set item at index.
Stores a copy of *value
at position index
, which must be less than the size of the list. NOTE: value
WILL BE EVALUATED TWICE.
#define uproc_list_append | ( | list, | |
value | |||
) | uproc_list_append_safe((list), (value), sizeof *(value)) |
Append item to list.
Stores a copy of *value
at the end of the list. NOTE: value
WILL BE EVALUATED TWICE.
#define uproc_list_extend | ( | list, | |
values, | |||
n | |||
) | uproc_list_extend_safe((list), (values), (n), sizeof *(values)) |
Append array of items.
Appends the n
elements of values
to the end of the list.
NOTE: values
WILL BE EVALUATED TWICE.
#define uproc_list_pop | ( | list, | |
value | |||
) | uproc_list_pop_safe((list), (value), sizeof *(value)) |
Get and remove the last item.
NOTE: value
WILL BE EVALUATED TWICE.
uproc_list* uproc_list_create | ( | size_t | value_size | ) |
Create an empty list.
value_size | size of the stored values |
void uproc_list_destroy | ( | uproc_list * | list | ) |
Destroy list object.
void uproc_list_clear | ( | uproc_list * | list | ) |
Remove all items.
int uproc_list_add | ( | uproc_list * | list, |
const uproc_list * | src | ||
) |
Append all elements of another list.
Extends list
by the items of src
. Both lists must be created with the same value_size
argument to uproc_list_create().
long uproc_list_size | ( | const uproc_list * | list | ) |
Returns the number of items.
void uproc_list_map | ( | const uproc_list * | list, |
void(*)(void *, void *) | func, | ||
void * | opaque | ||
) |
Apply function to all items.
The first argument passed to func
is a pointer to one item of the list. This is not a copy, so modifying it will also affect the stored value. The second argument to func
is the user-supplied opaque
pointer.
list | list instance |
func | function to call |
opaque | second argument to function |