This provides a thread-safe implementation of a linked list which can be used with any data type.
List comparison function. This is supplied by a client when inserting an element in the middle of the list. The list will always insert a smaller element in front of a larger element.
- Returns
- TRUE: lhs < rhs FALSE: lhs >= rhs
Single element in the list
Linked list type. Clients shouldn't modify this directly. Use the provided API functions to add new elements. The public members are only for debug purposes.
Create a new linked list.
- Returns
- Pointer to new queue (NULL on failure).
Destroy a linked list.
- Parameters
-
Insert an element into the list. The location where the element is inserted is determined using the supplied comparison function. Smaller elements are inserted in front of larger elements.
- Parameters
-
list | List to add to |
element | The element to insert |
compare | Comparison function supplied by the client |
Remove the last element in the list.
- Parameters
-
- Returns
- Pointer to the last element (or NULL if empty)
Remove the first element in the list.
- Parameters
-
- Returns
- Pointer to the first element (or NULL if empty)
Add an element to the back of the list.
- Parameters
-
list | List to add to |
element | The element to add |
Add an element to the front of the list.
- Parameters
-
list | List to add to |
element | The element to add |