[zeromq-dev] [ZFL] list class
Martin Hurton
hurtonm at gmail.com
Thu Oct 14 14:59:05 CEST 2010
Hi,
I plan to extend zfl library with a class for list manipulation.
Below is the first draft of the function interface.
Comments and suggestions would be appreciated.
- mh
typedef struct _zfl_list zfl_base_t;
typedef struct _zfl_list_element zfl_list_element_t;
// Create a new linked list.
zfl_list_t *
zfl_list_new ();
// Destroy the list and all its elements. Function frees
// all values stored in the list.
void
zfl_list_destroy (zfl_list_t *self);
// Insert the element at the end of the list.
void
zfl_list_append (zfl_list_t *self, void *val);
// Insert the element after a given element. Returns new element.
zfl_list_element_t *
zfl_list_insert_after (zfl_list_element_t *el, void *val);
// Insert the element before a given element. Returns new element.
zfl_list_element_t *
zfl_list_insert_before (zfl_list_element_t *el, void *val);
// Remove the element from the list.
void
zfl_list_remove (zfl_list_element_t *el);
// Return the value of the element.
void *
zfl_list_value (zfl_list_t *self);
// Return the number of elements in the list.
size_t
zfl_list_len (zfl_list_t *self);
// Return the first element or NULL, if the list is empty.
zfl_list_element_t *
zfl_list_first (zfl_list_t *self);
// Return the last element or NULL, if the list is empty.
zfl_list_element_t *
zfl_list_last (zfl_list_t *self);
// Return the element successor. If the element is the last one, the
// function returns NULL.
zfl_list_element_t *
zfl_list_next (zfl_list_element_t *el);
// Return the element's predecessor or NULL. If the element is the first
// one, the function returns NULL.
zfl_list_element_t *
zfl_list_prev (zfl_list_element_t *el);
// Selftest.
void
zfl_list_test ();
More information about the zeromq-dev
mailing list