Veritable Lasagna
An Allocator & Data Structure Library for C.
|
Functions | |
void | vlListInit (vl_linked_list *list, vl_memsize_t elementSize) |
Initializes the specified list instance. | |
vl_linked_list * | vlListNew (vl_memsize_t elementSize) |
Allocates on the heap, initializes, and returns a list instance. | |
void | vlListDelete (vl_linked_list *list) |
Deletes the specified list instance. | |
vl_list_iter | vlListPushFront (vl_linked_list *list, const void *elem) |
Adds a new element to the front of the list. | |
void | vlListPopFront (vl_linked_list *list) |
Removes whatever element is at the front of the list. | |
vl_list_iter | vlListPushBack (vl_linked_list *list, const void *elem) |
Adds a new element to the end of the list. | |
void | vlListPopBack (vl_linked_list *list) |
Removes whatever element is at the end of the list. | |
vl_list_iter | vlListInsertAfter (vl_linked_list *list, vl_list_iter target, const void *elem) |
Inserts an element immediately after the specified target. | |
vl_list_iter | vlListInsertBefore (vl_linked_list *list, vl_list_iter target, const void *elem) |
Inserts an element immediately before the specified target. | |
vl_linked_list * | vlListClone (const vl_linked_list *src, vl_linked_list *dest) |
Clones the specified list to another. | |
int | vlListCopy (vl_linked_list *src, vl_list_iter begin, vl_list_iter end, vl_linked_list *dest, vl_list_iter after) |
Copies a range of elements from one list to another. | |
void | vlListSort (vl_linked_list *list, vl_compare_function compareFunction) |
Sorts the specified list in-place using the given comparator. | |
vl_list_iter | vlListFind (vl_linked_list *src, const void *element) |
Performs an iterative search on the specified list. | |
void | vlListRemove (vl_linked_list *list, vl_list_iter iter) |
Removes the specified element from the list. | |
vl_list_iter | vlListNext (vl_linked_list *list, vl_list_iter iter) |
Returns next adjacent iterator, or VL_LIST_ITER_INVALID if no such element exists. | |
vl_list_iter | vlListPrev (vl_linked_list *list, vl_list_iter iter) |
Returns the previous adjacent iterator, or VL_LIST_ITER_INVALID if no such element exists. | |
vl_transient * | vlListSample (vl_linked_list *list, vl_list_iter iter) |
Returns a pointer to the element data for the specified iterator. | |
vl_linked_list * vlListClone | ( | const vl_linked_list * | src, |
vl_linked_list * | dest ) |
Clones the specified list to another.
Clones the entirety of the src list to the dest list.
The 'src' list pointer must be non-null and initialized. The 'dest' list pointer may be null, but if it is not null it must be initialized.
If the 'dest' list pointer is null, a new list is created via vlListNew. Otherwise, its element size is set to the source's and all of its existing data is replaced.
src | |
dest |
int vlListCopy | ( | vl_linked_list * | src, |
vl_list_iter | begin, | ||
vl_list_iter | end, | ||
vl_linked_list * | dest, | ||
vl_list_iter | after ) |
Copies a range of elements from one list to another.
Both the src list and the dest list must have equivalent element sizes, otherwise this is a no-op.
This is an inclusive range, and as such, the elements referred to by the begin and end iterators are also copied to the target list.
The begin and end iterators are expected to be in logical iterative order, meaning that if iterating through the entire src list, begin would be found before end.
src | source list pointer |
begin | iterator to start the copy at, or VL_LIST_ITER_INVALID for the beginning of the list. |
end | iterator to end the copy after, or VL_LIST_ITER_INVALID for the end of the list. |
dest | destination buffer pointer |
after | the iterator to insert elements after, or VL_LIST_ITER_INVALID for the end of the destination. |
void vlListDelete | ( | vl_linked_list * | list | ) |
Deletes the specified list instance.
The specified list should be created via vlListNew.
list | pointer |
vl_list_iter vlListFind | ( | vl_linked_list * | src, |
const void * | element ) |
Performs an iterative search on the specified list.
This will return an iterator to the first instance of the specified element that was found.
Returns VL_LIST_ITER_INVALID if the element could not be found.
src | source list pointer |
element | pointer to the element to compare against |
void vlListInit | ( | vl_linked_list * | list, |
vl_memsize_t | elementSize ) |
Initializes the specified list instance.
The initialized list should be freed via vlListFree.
list | pointer |
elementSize | size of a single list element, in bytes. |
vl_list_iter vlListInsertAfter | ( | vl_linked_list * | list, |
vl_list_iter | target, | ||
const void * | elem ) |
Inserts an element immediately after the specified target.
Element data is copied to the internal pool allocator.
list | pointer |
target | iterator to element that will have something inserted after it. |
elem | pointer |
vl_list_iter vlListInsertBefore | ( | vl_linked_list * | list, |
vl_list_iter | target, | ||
const void * | elem ) |
Inserts an element immediately before the specified target.
Element data is copied to the internal pool allocator.
list | pointer |
target | iterator to element that will have something inserted before it. |
elem |
vl_linked_list * vlListNew | ( | vl_memsize_t | elementSize | ) |
Allocates on the heap, initializes, and returns a list instance.
elementSize | size of a single list element, in bytes. |
vl_list_iter vlListNext | ( | vl_linked_list * | list, |
vl_list_iter | iter ) |
Returns next adjacent iterator, or VL_LIST_ITER_INVALID if no such element exists.
list | pointer |
iter | node iterator |
void vlListPopBack | ( | vl_linked_list * | list | ) |
Removes whatever element is at the end of the list.
This is a no-op if the list is empty.
list | pointer |
void vlListPopFront | ( | vl_linked_list * | list | ) |
Removes whatever element is at the front of the list.
This is a no-op if the list is empty.
list | pointer |
vl_list_iter vlListPrev | ( | vl_linked_list * | list, |
vl_list_iter | iter ) |
Returns the previous adjacent iterator, or VL_LIST_ITER_INVALID if no such element exists.
list | pointer |
iter | node iterator |
vl_list_iter vlListPushBack | ( | vl_linked_list * | list, |
const void * | elem ) |
Adds a new element to the end of the list.
Element data is copied to the internal pool allocator.
list | pointer |
elem | pointer to element data |
vl_list_iter vlListPushFront | ( | vl_linked_list * | list, |
const void * | elem ) |
Adds a new element to the front of the list.
Element data is copied to the internal pool allocator.
list | pointer |
elem | pointer to element data |
void vlListRemove | ( | vl_linked_list * | list, |
vl_list_iter | iter ) |
Removes the specified element from the list.
The underlying node is returned to the underlying node pool for reuse, without modifying its discarded data.
list | pointer |
iter | node iterator. |
vl_transient * vlListSample | ( | vl_linked_list * | list, |
vl_list_iter | iter ) |
Returns a pointer to the element data for the specified iterator.
list | pointer |
iter | node iterator |
void vlListSort | ( | vl_linked_list * | src, |
vl_compare_function | cmp ) |
Sorts the specified list in-place using the given comparator.
This function implements an iterative merge sort. Elements are not copied in this operation, but rather the links between them are modified.
The list is split into a "forest" in the underlying node pool, briefly holding a variety of sub-lists which are later merged back together.
src | source list pointer |
cmp | comparator function |