|init||The linkedlist_init function initializes a linkedlist object. The linkedlist will accepts no more than max_size items. If max_size is zero the list will accept no more than MAX_INT items. Memory for list elements will be allocated from the allocator al. It may be necessary to call linkedlist_deinit to release memory from the allocator al.|
|deinit||The linkedlist_deinit function calls the data_del function if it is not NULL with each data pointer in the list and the context parameter context and then releases memory allocated for list elements.|
|del||The linkedlist_del function deinitializes the list l with the linkedlist_deinit function before freeing l itself.|
|clear||The linkedlist_clear function clears the list of all elements. If the data_del function is not NULL it will be called with the context argument and each data pointer in the list before releasing memory for list elements.|
|add||The linkedlist_add function appends a data pointer to the end of the list. If the list has max_size elements, -1 is returned and errno is set to ERANGE.|
|insert||inserts a data pointer before the item at idx. Ifidxequals the size of the list, the data pointer will be appended to the list.|
linkedlist_insert_sorted function inserts the data pointer
data into the linked list
l in a position determined by the comparison function
cmp which is defined as follows:
This function will be called repeatedly with the new data pointer and each data pointer in the list until the insertion is complete or an error occurs. The context parameter is passed as-is. The following describes the outcome of the insertion based on the return value of the
> 0 - No operation is performed. The next data element in the list is compared.
|The linkedlist_is_empty function returns non-zero if the list is empty and zero if it is not empty.|
|size||The linkedlist_size function returns the number of items in the list.|
|get||The linkedlist_get function retrieves an item from the list by index. If elements are accessed forward-sequentially each call is an O(1) operation.|
|The linkedlist_get_last function returns the last data pointer int the list or a null pointer if the list is empty.|
Enumerate each element in the list. The
linkedlist_iterate function initializes the
iter object to point to the first item in the list. Each subsequent call to
linkedlist_next returns the next element in the list or
NULL if all elements have been enumerated. The elements are returned in order.
Because linkedlist uses an element index for the state of an interator, after a data object returned by linkedlist_next is removed a subsequent call to linkedlist_next will skip an element. Therefore, to remove elements during iteration, linkedlist_get should be used instead. This will have no performance impact as sequential access is O(1) optimized.
To enumerate each element in a list the following code might be used:
|remove||The linkedlist_remove function removes the data pointer at idx from the list. Please refer to the description of linkedlist_iterate for important information regarding the removal of elements during an iteration.|
|The linkedlist_remove_data function removes the data pointer data from the list l. Note that if the key is not returned or freed -- that operation must be performed independantly if necessary. Also, please refer to the description of linkedlist_iterate for important information regarding the removal of elements during an iteration.|
|The linkedlist_remove_last function removes the last data pointer in the list.|
init The linkedlist_init function returns -1 if sets errno to an appropriate value if the operation failed or 0 if the list was successfully initialized. deinit The linkedlist_deinit function returns -1 and sets errno to an appropriate value if the operation failed or 0 if the list was successfully deinitialized. new The linkedlist_new function allocates memory from the allocator al, initializes it with the linkedlist_init function and returns a pointer to the a new linkedlist object. If memory for the linkedlist cannot be allocated a null pointer is returned and errno is set appropriately. add The linkedlist_insert function returns 0 if the operation was successful and -1 if an error occurred in which case errno will be set appropriately. insert The linkedlist_insert function returns 0 if the operation was successful and -1 if an error occurred in which case errno will be set appropriately. insert_sorted The linkedlist_insert_sorted function returns 0 if the operation was successful and -1 if an error occurred in which case errno will be set appropriately. get The linkedlist_get function returns the data pointer being retrieved. If the specified idx was out of range, a null pointer is returned and errno is set to ERANGE. next The linkedlist_next function returns the next data pointer in the list or NULL if all elements have been enumerated. remove The linkedlist_remove function returns the data pointer removed from the list. remove_data The linkedlist_remove_data function returns the data pointer removed from the list. remove_last The linkedlist_remove_last function returns the data pointer removed from the list.
|libmba-0.9.1||LINKEDLIST (3m)||Apr 29, 2005|