Collections is a C library that implements useful data structures for developers. At this time, a singly linked list and a stack have been implemented. Trees, maps, and more are also on the way.
Stay tuned!
A linked list is a list of nodes, where each node contains a data element and a pointer to the next node.
A linkedlist can be instantiated via alloc_ll(), which returns
a pointer to a newly allocated linked list.
To add an element, call ll_add(linkedlist *list, void *element),
where list is a pointer to the linked list to add the element to,
and element is a pointer to the element you wish to add. This function
returns the macro LINKEDLIST_OK on success.
To get an element, call ll_get(linkedlist *list, unsigned int position),
where list is a pointer to the linked list to get the
element from, and position is the position of the element you
wish to fetch from the list.
This function returns a void pointer to the element on success,
and LINKEDLIST_OUT_OF_BOUNDS_EX if position
is outside the bounds of the list.
Remember to cast the result of this function into a pointer to of the element's type before dereferencing!
To delete an element, call ll_delete(linkedlist *list, unsigned int position),
where list is a pointer to the linked list to delete the element from, and
position is the position of the element to delete from the list.
This function returns LINKEDLIST_OK on success and LINKEDLIST_OUT_OF_BOUNDS_EX
if position is outside of the bounds of the list.
To get the size of a list, call ll_size(linkedlist *list), where
list is a pointer to the list to get the size of. This function returns
the list's size as an unsigned int.