![]() |
wget2 2.3.0
|
Data Structures | |
| struct | wget_list_st |
Typedefs | |
| typedef struct wget_list_st | wget_list |
Functions | |
| void * | wget_list_append (wget_list **list, const void *data, size_t size) |
| void * | wget_list_prepend (wget_list **list, const void *data, size_t size) |
| void | wget_list_remove (wget_list **list, void *elem) |
| void * | wget_list_getfirst (const wget_list *list) |
| void * | wget_list_getlast (const wget_list *list) |
| void * | wget_list_getnext (const void *elem) |
| int | wget_list_browse (const wget_list *list, wget_list_browse_fn *browse, void *context) |
| void | wget_list_free (wget_list **list) |
Circular doubly linked lists provide fast insertion, removal and iteration in either direction.
Each element has pointers to the next and the previous element.
Iteration can be done by calling the wget_list_browse() function, so the list structure doesn't need to be exposed.
This datatype is used by the Wget2 tool to implement the job queue (append and remove).
See wget_list_append() for an example on how to use lists.
| typedef struct wget_list_st wget_list |
Type for double linked lists and list entries.
| void * wget_list_append | ( | wget_list ** | list, |
| const void * | data, | ||
| size_t | size ) |
| [in] | list | Pointer to Pointer to a circular doubly linked list |
| [in] | data | Pointer to data to be inserted |
| [in] | size | Size of data in bytes |
Append an element to the end of the list.
size bytes at data will be copied and appended to the list.
A pointer to the new element will be returned.
Example:
| void * wget_list_prepend | ( | wget_list ** | list, |
| const void * | data, | ||
| size_t | size ) |
| [in] | list | Pointer to Pointer to a circular doubly linked list |
| [in] | data | Pointer to data to be inserted |
| [in] | size | Size of data in bytes |
Insert an entry at the beginning of the list. size bytes at data will be copied and prepended to the list.
A pointer to the new element will be returned. It must be freed by wget_list_remove() or implicitly by wget_list_free().
| void wget_list_remove | ( | wget_list ** | list, |
| void * | elem ) |
| [in] | list | Pointer to Pointer to a circular doubly linked list |
| [in] | elem | Pointer to a list element returned by wget_list_append() or wget_list_prepend() |
Remove an element from the list.
| void * wget_list_getfirst | ( | const wget_list * | list | ) |
| [in] | list | Pointer to a circular doubly linked list |
Get the first element of a list.
| void * wget_list_getlast | ( | const wget_list * | list | ) |
| [in] | list | Pointer to a circular doubly linked list |
Get the last element of a list.
| void * wget_list_getnext | ( | const void * | elem | ) |
| [in] | elem | Pointer to an element of a linked list |
Get the next element of a list.
| int wget_list_browse | ( | const wget_list * | list, |
| wget_list_browse_fn * | browse, | ||
| void * | context ) |
| [in] | list | Pointer to a circular doubly linked list |
| [in] | browse | Pointer to callback function which is called for every element in the list. If the callback functions returns a value not equal to zero, browsing is stopped and this value will be returned by wget_list_browse. |
| [in] | context | The context handle that will be passed to the callback function |
list is NULL (empty)Iterate through all entries of the list and call the function browse for each.
| void wget_list_free | ( | wget_list ** | list | ) |
| [in] | list | Pointer to Pointer to a circular doubly linked list |
Freeing the list and it's entry.