// Copyright 2023 alexevier // licensed under the zlib license #ifndef lexlib_linkedList_h #define lexlib_linkedList_h #include"common.h" #include #include // structs // struct LexlibLinkedNode { void* data; struct LexlibLinkedNode* next; }; struct LexlibLinkedList { struct LexlibLinkedNode* head; size_t count; }; // typedefs // #ifndef __cplusplus typedef struct LexlibLinkedNode LexlibLinkedNode; typedef struct LexlibLinkedList LexlibLinkedList; #endif // creates a new linkedlist LEXLIB_EXTERN struct LexlibLinkedList lexlibLinkedListNew(void); // deletes a linkedlist. LEXLIB_EXTERN void lexlibLinkedListDelete(struct LexlibLinkedList* list); // deletes a linkedList and frees the data. LEXLIB_EXTERN void lexlibLinkedListFree(struct LexlibLinkedList* list); // get an element at a index, will return the data or NULL if an error occurred. LEXLIB_EXTERN void* lexlibLinkedListGet(struct LexlibLinkedList* list, size_t index); // will not copy the data! LEXLIB_EXTERN uint8_t lexlibLinkedListAdd(struct LexlibLinkedList* list, void* data); // copies the data LEXLIB_EXTERN uint8_t lexlibLinkedListAddCopy(struct LexlibLinkedList* list, void* data, size_t dataSize); #endif