feat(ll)!: add new ll function and rename insert

ds_*ll_insert -> ds_*ll_append to better reflect what it does and there
is now ds_*ll_add to add data anywhere in the ll.
This commit is contained in:
Squibid 2025-11-15 21:39:57 -05:00
parent 46b0219ab4
commit 69dc1dcb45
Signed by: squibid
GPG key ID: BECE5684D3C4005D
4 changed files with 104 additions and 16 deletions

32
ds.h
View file

@ -55,24 +55,46 @@ ds_sll_t *ds_sll_new_node(void *data);
ds_dll_t *ds_dll_new_node(void *data);
/**
* @brief data to insert into a singly linked list. This will use
* @brief data to add at x of a singly linked list. This will use
* ds_sll_new_node to create the node for you.
*
* @param ll singly linked list
* @param data data you want to add
* @param x the position to add it at
* @return 0 on success
*/
int ds_sll_insert(ds_sll_t *ll, void *data);
int ds_sll_add(ds_sll_t **ll, void *data, unsigned x);
/**
* @brief data to insert into a doubly linked list. This will use
* ds_sll_new_node to create the node for you.
* @brief data to add at x of a doubly linked list. This will use
* ds_dll_new_node to create the node for you.
*
* @param ll doubly linked list
* @param data data you want to add
* @param x the position to add it at
* @return 0 on success
*/
int ds_dll_insert(ds_dll_t *ll, void *data);
int ds_dll_add(ds_dll_t **ll, void *data, unsigned x);
/**
* @brief data to append to the end of a singly linked list. This will use
* ds_sll_new_node to create the node for you.
*
* @param ll singly linked list
* @param data data you want to append
* @return 0 on success
*/
int ds_sll_append(ds_sll_t *ll, void *data);
/**
* @brief data to append to the end of a doubly linked list. This will use
* ds_dll_new_node to create the node for you.
*
* @param ll doubly linked list
* @param data data you want to append
* @return 0 on success
*/
int ds_dll_append(ds_dll_t *ll, void *data);
/**
* @brief remove an index from a singly linked list