can_wizard/components/C-Linked-List/list.h
Данила Горнушко 28c7242587 added function to destroy list
2023-11-29 12:01:20 +03:00

30 lines
800 B
C

#ifndef LIST_H_DEF
#define LIST_H_DEF
typedef struct List {
void* data;
struct List* next;
} List;
// Push data to the end of the list.
void list_push(List** head, void* data);
// Remove the final element of the list and return its data.
void* list_pop(List** head);
// Insert the data object to the beginning of the list.
void list_insert(List** head, void* data);
// Get the size of the list.
unsigned int list_sizeof(List* head);
// Get the data of the node at the given ordinal number in the list.
List* list_get(List* head, unsigned int index);
// Delete the item in the list at the given ordinal location (1 is the first).
void list_remove(List** head, unsigned int index);
// Remove all element of the list and set the given ptr to NULL
void list_destroy(List** head);
#endif