|
clist
A multi-mode C linked list library/implementation
|
The main module. Please note that as of now, not all functions have been implemented. Only the documentation for the function prototype is displayed here. More...
Files | |
| file | clist.h |
| Provides the function prototypes and the list structures. This header provides the prototypes of the list functions for the source files and provides the node and the list structure. | |
| file | clist.c |
| Function definitions for clist.hThis file provides function definitions for clist.h. | |
Data Structures | |
| struct | node |
| A single node element for the list. More... | |
| struct | clist |
| A double-way linked list. More... | |
Functions | |
| struct clist * | clist_init (size_t item_size) |
| Create a clist. More... | |
| size_t | clist_free (struct clist *clist) |
| Frees a list. More... | |
| void * | clist_append (struct clist *clist, const void *item) |
| Append an item. More... | |
| void * | clist_pop (struct clist *clist) |
| Pops the last item from a clist. More... | |
| size_t | clist_length (const struct clist *clist) |
| Returns the length of the list. More... | |
| void * | clist_jump (struct clist *clist, unsigned long index) |
| Jump to the given index. More... | |
| void * | clist_read (const struct clist *clist) |
| Return the item on the current index. More... | |
| void * | clist_write (const struct clist *clist, void *item) |
| Replace the item on the current index. More... | |
| void * | clist_insert (struct clist *clist, void *item, unsigned long index) |
| Insert an item. More... | |
| void * | clist_remove (struct clist *clist, unsigned long index) |
| Remove an item. More... | |
The main module. Please note that as of now, not all functions have been implemented. Only the documentation for the function prototype is displayed here.
| void * clist_append | ( | struct clist * | clist, |
| const void * | item | ||
| ) |
Append an item.
Append an item at the end of the list while still staying on the current index. clist::list_length is updated accordingly.
| clist | The list to be operated on. This has to be a modifiable pointer pointing to the list, since we are modifying clist::end. The item will be copied onto the list instead of being linked onto, i.e. using memcpy. |
| item | A pointer to the item that has to to be appended. |
| size_t clist_free | ( | struct clist * | clist | ) |
Frees a list.
The function frees all memory which was allocated for the list.
| clist | The pointer to a clist which (including all its items) should be freed. |
| struct clist * clist_init | ( | size_t | item_size | ) |
Create a clist.
This function is used to create and initialize a clist, performing all necessary steps while doing this.
| item_size | Specifies how big one "item" is. An item is a block of data that is defined by you and will be stored on the linked list. No explicit type for an item is required, just provide the size of the item. |
| void * clist_insert | ( | struct clist * | clist, |
| void * | item, | ||
| unsigned long | index | ||
| ) |
Insert an item.
On the list, insert an item after the index specified by index. The current index (clist::current) is preserved.
| clist | The list to be operated on. |
| item | The item to insert. |
| index | The index after which to insert the item. |
| void * clist_jump | ( | struct clist * | clist, |
| unsigned long | index | ||
| ) |
Jump to the given index.
Jumps to the given index and returns the item on that index.
| clist | The list to be operated on. |
| index | The index to jump to. |
| size_t clist_length | ( | const struct clist * | clist | ) |
Returns the length of the list.
Returns clist::list_length.
| clist | The list to be operated on. |
| void * clist_pop | ( | struct clist * | clist | ) |
Pops the last item from a clist.
The last item is popped from a clist. clist::list_length is updated accordingly. If clist::current is the last index node, i.e. clist::current will be popped after this function, move one node back.
| clist | The list to be operated on. |
| void * clist_read | ( | const struct clist * | clist | ) |
Return the item on the current index.
Returns the item on the current index.
| clist | The list to be operated on. |
| void * clist_remove | ( | struct clist * | clist, |
| unsigned long | index | ||
| ) |
Remove an item.
Removes the item specified by index. If the current index (clist::current) is to be removed, move one index back. If this is not possible, move one index forward. If neither of both is possible, clist::current is set to NULL.
| clist | The list to be operated on. |
| index | The index which has to be removed. |
| void * clist_write | ( | const struct clist * | clist, |
| void * | item | ||
| ) |
Replace the item on the current index.
Replaces the item on the current index, with item.
| clist | The list to be operated on. |
| item | The item that should replace the item on the current index. |