|
libcute 0.1
|
#include "macro.h"#include "memory/allocator.h"#include "object/optional.h"#include "object/result.h"#include "object/destructor.h"#include "utility.h"#include <nostd.h>#include <stddef.h>

Go to the source code of this file.
Classes | |
| struct | cu_List_Node |
| Node within a singly linked list. More... | |
| struct | cu_List |
| Singly linked list container. More... | |
Typedefs | |
| typedef struct cu_List_Node | cu_List_Node |
| Node within a singly linked list. | |
Enumerations | |
| enum | cu_List_Error { CU_LIST_ERROR_NONE = 0 , CU_LIST_ERROR_OOM , CU_LIST_ERROR_INVALID_LAYOUT , CU_LIST_ERROR_INVALID , CU_LIST_ERROR_EMPTY } |
| Error codes returned by list operations. More... | |
Functions | |
| cu_List_Result | cu_List_create (cu_Allocator allocator, cu_Layout layout, cu_Destructor_Optional destructor) |
| Create an empty list. | |
| void | cu_List_destroy (cu_List *list) |
| Destroy a list and free all nodes. | |
| cu_List_Error_Optional | cu_List_push_front (cu_List *list, void *elem) |
| cu_List_Error_Optional | cu_List_pop_front (cu_List *list, void *out_elem) |
| cu_List_Error_Optional | cu_List_insert_after (cu_List *list, cu_List_Node *node, void *elem) |
| cu_List_Error_Optional | cu_List_insert_before (cu_List *list, struct cu_List_Node *node, void *elem) |
| bool | cu_List_iter (const cu_List *list, cu_List_Node **node, void **out_elem) |
| Iterate over the list. | |
Singly linked list container.
| enum cu_List_Error |
| cu_List_Result cu_List_create | ( | cu_Allocator | allocator, |
| cu_Layout | layout, | ||
| cu_Destructor_Optional | destructor | ||
| ) |
Create an empty list.
| allocator | allocator used for node storage |
| layout | layout describing each element |
| destructor | optional element destructor |
| cu_List_Error_Optional cu_List_insert_after | ( | cu_List * | list, |
| cu_List_Node * | node, | ||
| void * | elem | ||
| ) |
Insert a new element after node.

| cu_List_Error_Optional cu_List_insert_before | ( | cu_List * | list, |
| struct cu_List_Node * | node, | ||
| void * | elem | ||
| ) |
Insert a new element before node.

| bool cu_List_iter | ( | const cu_List * | list, |
| cu_List_Node ** | node, | ||
| void ** | out_elem | ||
| ) |
Iterate over the list.
The iteration state is held in node. Pass NULL for the first call.
| list | list to iterate |
| node | current node, updated on success |
| out_elem | pointer receiving the element data |
| cu_List_Error_Optional cu_List_pop_front | ( | cu_List * | list, |
| void * | out_elem | ||
| ) |
Remove the first element and copy it into out_elem.
| cu_List_Error_Optional cu_List_push_front | ( | cu_List * | list, |
| void * | elem | ||
| ) |
Add an element to the front of the list.