include/Zycore/List.h(3)
π include/Zycore/List.h π
Library Functions Manual Β· section 3 π¦
okay bestie, sit down, grab a strawberry π, because this is THE header for a doubly linked list and she is serving. no cap, every flag, every param, every little "this might explode" warning is right here. iykyk π
β¨ NAME β¨
include/Zycore/List.h πΈ
π SYNOPSIS π
#include <Zycore/Allocator.h>
#include <Zycore/Object.h>
#include <Zycore/Status.h>
#include <Zycore/Types.h>
π Classes
struct ZyanListNode_struct ZyanList_
π Macros
#define ZYAN_LIST_INITIALIZER#define ZYAN_LIST_GET(type, node)
π¦ Typedefs
typedef struct ZyanListNode_ ZyanListNodetypedef struct ZyanList_ ZyanList
π Functions
ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus ZyanListInit (ZyanList *list, ZyanUSize element_size, ZyanMemberProcedure destructor)
ZYCORE_EXPORT ZyanStatus ZyanListInitEx (ZyanList *list, ZyanUSize element_size, ZyanMemberProcedure destructor, ZyanAllocator *allocator)
ZYCORE_EXPORT ZyanStatus ZyanListInitCustomBuffer (ZyanList *list, ZyanUSize element_size, ZyanMemberProcedure destructor, void *buffer, ZyanUSize capacity)
ZYCORE_EXPORT ZyanStatus ZyanListDestroy (ZyanList *list)
ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus ZyanListDuplicate (ZyanList *destination, const ZyanList *source)
ZYCORE_EXPORT ZyanStatus ZyanListDuplicateEx (ZyanList *destination, const ZyanList *source, ZyanAllocator *allocator)
ZYCORE_EXPORT ZyanStatus ZyanListDuplicateCustomBuffer (ZyanList *destination, const ZyanList *source, void *buffer, ZyanUSize capacity)
ZYCORE_EXPORT ZyanStatus ZyanListGetHeadNode (const ZyanList *list, const ZyanListNode **node)
ZYCORE_EXPORT ZyanStatus ZyanListGetTailNode (const ZyanList *list, const ZyanListNode **node)
ZYCORE_EXPORT ZyanStatus ZyanListGetPrevNode (const ZyanListNode **node)
ZYCORE_EXPORT ZyanStatus ZyanListGetNextNode (const ZyanListNode **node)
ZYCORE_EXPORT const void * ZyanListGetNodeData (const ZyanListNode *node)
ZYCORE_EXPORT ZyanStatus ZyanListGetNodeDataEx (const ZyanListNode *node, const void **value)
ZYCORE_EXPORT void * ZyanListGetNodeDataMutable (const ZyanListNode *node)
ZYCORE_EXPORT ZyanStatus ZyanListGetNodeDataMutableEx (const ZyanListNode *node, void **value)
ZYCORE_EXPORT ZyanStatus ZyanListSetNodeData (const ZyanList *list, const ZyanListNode *node, const void *value)
ZYCORE_EXPORT ZyanStatus ZyanListPushBack (ZyanList *list, const void *item)
ZYCORE_EXPORT ZyanStatus ZyanListPushFront (ZyanList *list, const void *item)
ZYCORE_EXPORT ZyanStatus ZyanListEmplaceBack (ZyanList *list, void **item, ZyanMemberFunction constructor)
ZYCORE_EXPORT ZyanStatus ZyanListEmplaceFront (ZyanList *list, void **item, ZyanMemberFunction constructor)
ZYCORE_EXPORT ZyanStatus ZyanListPopBack (ZyanList *list)
ZYCORE_EXPORT ZyanStatus ZyanListPopFront (ZyanList *list)
ZYCORE_EXPORT ZyanStatus ZyanListRemove (ZyanList *list, const ZyanListNode *node)
ZYCORE_EXPORT ZyanStatus ZyanListRemoveRange (ZyanList *list, const ZyanListNode *first, const ZyanListNode *last)
ZYCORE_EXPORT ZyanStatus ZyanListClear (ZyanList *list)
ZYCORE_EXPORT ZyanStatus ZyanListResize (ZyanList *list, ZyanUSize size)
ZYCORE_EXPORT ZyanStatus ZyanListResizeEx (ZyanList *list, ZyanUSize size, const void *initializer)
ZYCORE_EXPORT ZyanStatus ZyanListGetSize (const ZyanList *list, ZyanUSize *size)
π« Detailed Description
so what IS this? it's a doubly linked list. that's the whole vibe. girl goes both ways (forward and backward through nodes) and we love that for her π
πΈ Macro Definition Documentation πΈ
#define ZYAN_LIST_GET( type, node)
Value:
(*(const type*)ZyanListGetNodeData(node))
grabs the data value sitting inside the node you hand her. one line, no thoughts, just dereference β¨
Parameters
typeβ the value type you're manifesting. the desired one. πnodeβ a pointer to theZyanListNodestruct.
Returns
the data value of the given node. periodt.
β οΈ lowkey important bestie: note that this macro is unsafe and might dereference a null-pointer. like, she WILL do it. no guardrails. be careful π
#define ZYAN_LIST_INITIALIZER
Value:
{ \
/* allocator */ ZYAN_NULL, \
/* size */ 0, \
/* element_size */ 0, \
/* head */ ZYAN_NULL, \
/* destructor */ ZYAN_NULL, \
/* tail */ ZYAN_NULL, \
/* buffer */ ZYAN_NULL, \
/* capacity */ 0, \
/* first_unused */ ZYAN_NULL \
}
this one defines an uninitialized ZyanList instance. it's giving blank canvas, main character before the glow-up π
π¦ Typedef Documentation π¦
typedef struct ZyanList_ ZyanList
defines the ZyanList struct. that's her.
π«Ά heads up: every single field in this struct is to be treated as "private". any changes you make may lead to unexpected behavior. do not touch. hands off. π
typedef struct ZyanListNode_ ZyanListNode
defines the ZyanListNode struct. the little one. the building block. iconic in her own right.
π«Ά same deal: all fields in this struct should be considered "private". any changes may lead to unexpected behavior. no poking π
π₯ Function Documentation π₯
ZYCORE_EXPORT ZyanStatus ZyanListClear (ZyanList * list)
erases all elements of the list. not some. all. clean slate energy β¨
Parameters
listβ a pointer to theZyanListinstance.
Returns
a zyan status code.
ZYCORE_EXPORT ZyanStatus ZyanListDestroy (ZyanList * list)
destroys the given ZyanList instance. she's done, she's logging off π
Parameters
listβ a pointer to theZyanListinstance.
Returns
a zyan status code.
ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus ZyanListDuplicate (ZyanList * destination, const ZyanList * source)
initializes a new ZyanList instance by duplicating an existing list. clone behavior, but make it cute π§
Parameters
destinationβ a pointer to the (uninitialized) destinationZyanListinstance.sourceβ a pointer to the source list.
Returns
a zyan status code.
the memory for the list gets dynamically allocated by the default allocator.
β οΈ finalization with ZyanListDestroy is required for all instances created by this function. don't forget her, bestie π
ZYCORE_EXPORT ZyanStatus ZyanListDuplicateCustomBuffer (ZyanList * destination, const ZyanList * source, void * buffer, ZyanUSize capacity)
initializes a new ZyanList instance by duplicating an existing list and configures it to use a custom user-defined buffer with a fixed size. diy queen π
Parameters
destinationβ a pointer to the (uninitialized) destinationZyanListinstance.sourceβ a pointer to the source list.bufferβ a pointer to the buffer that is used as storage for the elements.capacityβ the maximum capacity (number of bytes) of the buffer, including the space required for the list-nodes.
β οΈ this function will fail if the capacity of the buffer is not sufficient to store all elements of the source list. no room, no party π«
Returns
a zyan status code.
the buffer capacity required to store n elements of type T is calculated by:
size = n * sizeof(ZyanListNode) + n * sizeof(T)
π and the best part: finalization is not required for instances created by this function. she handles herself.
ZYCORE_EXPORT ZyanStatus ZyanListDuplicateEx (ZyanList * destination, const ZyanList * source, ZyanAllocator * allocator)
initializes a new ZyanList instance by duplicating an existing list and sets a custom allocator. choose your own adventure π
Parameters
destinationβ a pointer to the (uninitialized) destinationZyanListinstance.sourceβ a pointer to the source list.allocatorβ a pointer to aZyanAllocatorinstance.
Returns
a zyan status code.
β οΈ finalization with ZyanListDestroy is required for all instances created by this function.
ZYCORE_EXPORT ZyanStatus ZyanListEmplaceBack (ZyanList * list, void ** item, ZyanMemberFunction constructor)
constructs an item in-place at the end of the list. back of the line but make it glamorous π«Ά
Parameters
listβ a pointer to theZyanListinstance.itemβ receives a pointer to the new item.constructorβ the constructor callback orZYAN_NULL. the new item will be in an undefined state if no constructor was passed. π (yes, undefined. she's fresh out the box with no instruction manual.)
Returns
a zyan status code.
ZYCORE_EXPORT ZyanStatus ZyanListEmplaceFront (ZyanList * list, void ** item, ZyanMemberFunction constructor)
constructs an item in-place at the beginning of the list. front row seat, main character energy π
Parameters
listβ a pointer to theZyanListinstance.itemβ receives a pointer to the new item.constructorβ the constructor callback orZYAN_NULL. the new item will be in an undefined state if no constructor was passed. β οΈ
Returns
a zyan status code.
ZYCORE_EXPORT ZyanStatus ZyanListGetHeadNode (const ZyanList * list, const ZyanListNode ** node)
returns a pointer to the first ZyanListNode struct of the given list. the head. the one at the front. π
Parameters
listβ a pointer to theZyanListinstance.nodeβ receives a pointer to the firstZyanListNodestruct of the list.
Returns
a zyan status code.
ZYCORE_EXPORT ZyanStatus ZyanListGetNextNode (const ZyanListNode ** node)
receives a pointer to the next ZyanListNode struct linked to the passed one. keep it moving bestie β‘οΈ π¦
Parameters
nodeβ receives a pointer to the nextZyanListNodestruct linked to the passed one.
Returns
a zyan status code.
ZYCORE_EXPORT const void * ZyanListGetNodeData (const ZyanListNode * node)
returns a constant pointer to the data of the given node. look, don't touch π
Parameters
nodeβ a pointer to theZyanListNodestruct.
Returns
a constant pointer to the data of the given node, or ZYAN_NULL if an error occurred.
β¨ take a look at ZyanListGetNodeDataEx if you need a function that returns a zyan status code instead.
ZYCORE_EXPORT ZyanStatus ZyanListGetNodeDataEx (const ZyanListNode * node, const void ** value)
returns a constant pointer to the data of the given node. same energy as above, but she reports back properly π
Parameters
nodeβ a pointer to theZyanListNodestruct.valueβ receives a constant pointer to the data of the given node.
β¨ take a look at ZyanListGetNodeData if you need a function that directly returns a pointer.
Returns
a zyan status code.
ZYCORE_EXPORT void * ZyanListGetNodeDataMutable (const ZyanListNode * node)
returns a mutable pointer to the data of the given node. now we're editing, now we're changing things π₯
Parameters
nodeβ a pointer to theZyanListNodestruct.
Returns
a mutable pointer to the data of the given node, or ZYAN_NULL if an error occurred.
β¨ take a look at ZyanListGetPointerMutableEx instead β yes, that's the name, don't @ me β if you need a function that returns a zyan status code.
ZYCORE_EXPORT ZyanStatus ZyanListGetNodeDataMutableEx (const ZyanListNode * node, void ** value)
returns a mutable pointer to the data of the given node. the grown-up version. she signs the paperwork π
Parameters
nodeβ a pointer to theZyanListNodestruct.valueβ receives a mutable pointer to the data of the given node.
β¨ take a look at ZyanListGetNodeDataMutable if you need a function that directly returns a pointer.
Returns
a zyan status code.
ZYCORE_EXPORT ZyanStatus ZyanListGetPrevNode (const ZyanListNode ** node)
receives a pointer to the previous ZyanListNode struct linked to the passed one. yes she can go backwards. it's called range β¬
οΈ π
Parameters
nodeβ receives a pointer to the previousZyanListNodestruct linked to the passed one.
Returns
a zyan status code.
ZYCORE_EXPORT ZyanStatus ZyanListGetSize (const ZyanList * list, ZyanUSize * size)
returns the current size of the list.
Parameters
listβ A pointer to theZyanListinstance.sizeβ Receives the size of the list.
Returns β A zyan status code. π
ZyanListGetTailNode π¦
ZYCORE_EXPORT ZyanStatus ZyanListGetTailNode (const ZyanList * list, const
ZyanListNode ** node)
Returns a pointer to the last ZyanListNode struct of the given list. Lowkey the move when you need the tail without scrolling the whole thing, periodt.
Parameters
listβ A pointer to theZyanListinstance.nodeβ Receives a pointer to the lastZyanListNodestruct of the list.
Returns β A zyan status code. β¨
ZyanListInit π
ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus ZyanListInit (ZyanList * list,
ZyanUSize element_size, ZyanMemberProcedure destructor)
Initializes the given ZyanList instance. It's giving setup era, bestie.
Parameters
listβ A pointer to theZyanListinstance.element_sizeβ The size of a single element in bytes.destructorβ A destructor callback that is invoked every time an item is deleted, orZYAN_NULLif not needed.
Returns β A zyan status code.
The memory for the list elements is dynamically allocated by the default allocator.
Finalization with ZyanListDestroy is required for all instances created by this function. No skipping this, bestie. π«Ά
ZyanListInitCustomBuffer π
ZYCORE_EXPORT ZyanStatus ZyanListInitCustomBuffer (ZyanList * list,
ZyanUSize element_size, ZyanMemberProcedure destructor, void * buffer,
ZyanUSize capacity)
Initializes the given ZyanList instance and configures it to use a custom user defined buffer with a fixed size. Bespoke storage, no default allocator energy. πΈ
Parameters
listβ A pointer to theZyanListinstance.element_sizeβ The size of a single element in bytes.destructorβ A destructor callback that is invoked every time an item is deleted, orZYAN_NULLif not needed.bufferβ A pointer to the buffer that is used as storage for the elements.capacityβ The maximum capacity (number of bytes) of the buffer including the space required for the list-nodes.
Returns β A zyan status code.
The buffer capacity required to store n elements of type T is be calculated by: size = n * sizeof(ZyanListNode) + n * sizeof(T)
Finalization is not required for instances created by this function.
ZyanListInitEx π
ZYCORE_EXPORT ZyanStatus ZyanListInitEx (ZyanList * list, ZyanUSize
element_size, ZyanMemberProcedure destructor, ZyanAllocator * allocator)
Initializes the given ZyanList instance and sets a custom allocator. Choose your own allocator, main character move. π₯
Parameters
listβ A pointer to theZyanListinstance.element_sizeβ The size of a single element in bytes.destructorβ A destructor callback that is invoked every time an item is deleted, orZYAN_NULLif not needed.allocatorβ A pointer to aZyanAllocatorinstance.
Returns β A zyan status code.
Finalization with ZyanListDestroy is required for all instances created by this function. π
ZyanListPopBack π
ZYCORE_EXPORT ZyanStatus ZyanListPopBack (ZyanList * list)
Removes the last element of the list. Bye-bye, tail. β¨
Parameters
listβ A pointer to theZyanListinstance.
Returns β A zyan status code.
ZyanListPopFront π
ZYCORE_EXPORT ZyanStatus ZyanListPopFront (ZyanList * list)
Removes the firstelement of the list. (Yes, one word. The manpage really said that, and honestly? Iconic.) π
Parameters
listβ A pointer to theZyanListinstance.
Returns β A zyan status code.
ZyanListPushBack π₯
ZYCORE_EXPORT ZyanStatus ZyanListPushBack (ZyanList * list, const void *
item)
Adds a new item to the end of the list. Append slay. π¦
Parameters
listβ A pointer to theZyanListinstance.itemβ A pointer to the item to add.
Returns β A zyan status code.
ZyanListPushFront π
ZYCORE_EXPORT ZyanStatus ZyanListPushFront (ZyanList * list, const void *
item)
Adds a new item to the beginning of the list. Prepend princess. πΈ
Parameters
listβ A pointer to theZyanListinstance.itemβ A pointer to the item to add.
Returns β A zyan status code.
ZyanListRemove π―
ZYCORE_EXPORT ZyanStatus ZyanListRemove (ZyanList * list, const ZyanListNode
* node)
Removes the given node from the list. Targeted removal, no cap. π
Parameters
listβ A pointer to theZyanListinstance.nodeβ A pointer to theZyanListNodestruct.
Returns β A zyan status code.
ZyanListRemoveRange π§Ή
ZYCORE_EXPORT ZyanStatus ZyanListRemoveRange (ZyanList * list, const
ZyanListNode * first, const ZyanListNode * last)
Removes multiple nodes from the list. Range delete, we love a clean sweep. π
Parameters
listβ A pointer to theZyanListinstance.firstβ A pointer to the first node.lastβ A pointer to the last node.
Returns β A zyan status code.
ZyanListResize π¦
ZYCORE_EXPORT ZyanStatus ZyanListResize (ZyanList * list, ZyanUSize size)
Resizes the given ZyanList instance. Glow up or shrink, either way. π
Parameters
listβ A pointer to theZyanListinstance.sizeβ The new size of the list.
Returns β A zyan status code.
ZyanListResizeEx π
ZYCORE_EXPORT ZyanStatus ZyanListResizeEx (ZyanList * list, ZyanUSize size,
const void * initializer)
Resizes the given ZyanList instance. Same as above but with an initializer for new items, so new elements aren't just sitting there uninitialized. Very considerate. π
Parameters
listβ A pointer to theZyanListinstance.sizeβ The new size of the list.initializerβ A pointer to a value to be used as initializer for new items.
Returns β A zyan status code.
ZyanListSetNodeData π
ZYCORE_EXPORT ZyanStatus ZyanListSetNodeData (const ZyanList * list, const
ZyanListNode * node, const void * value)
Assigns a new data value to the given node. Data makeover, bestie. β¨
Parameters
listβ A pointer to theZyanListinstance.nodeβ A pointer to theZyanListNodestruct.valueβ The value to assign.
Returns β A zyan status code.
Author π
Generated automatically by Doxygen for Zycore from the source code.
That's the whole list vibe, bestie. This page is chillin' as Zycore Version 1.5.2.0 for include/Zycore/List.h(3). Stay slay. πβ¨π¦
π¦ where this page comes from
- ubuntu resolute: libzycore-doc 1.5.2-1build1 Β· MIT
- ubuntu stonking: libzycore-doc 1.5.2-1build1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms