libuproc  1.2.0
Data Structures | Macros | Functions
object uproc_list

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_listuproc_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...
 

Detailed Description

List of homogenous items (also known as "vector" or "arraylist")

Macro Definition Documentation

#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.

Parameters
listlist to copy from
bufbuffer to copy into
szsize of dest in bytes
Returns
the number of copied bytes, or how many bytes would have been copied, if this number exceeds 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,
 
)    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.

Function Documentation

uproc_list* uproc_list_create ( size_t  value_size)

Create an empty list.

Parameters
value_sizesize 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.

Parameters
listlist instance
funcfunction to call
opaquesecond argument to function