can_wizard/components/C-Linked-List/list.h

28 lines
709 B
C
Raw Permalink Normal View History

#ifndef LIST_H_DEF
2023-11-29 09:01:20 +00:00
#define LIST_H_DEF
typedef struct List {
void* data;
struct List* next;
} List;
2023-11-29 09:01:20 +00:00
// Push data to the end of the list.
void list_push(List** head, void* data);
2023-11-29 09:01:20 +00:00
// Remove the final element of the list and return its data.
void* list_pop(List** head);
2023-11-29 09:01:20 +00:00
// Insert the data object to the beginning of the list.
void list_insert(List** head, void* data);
2023-11-29 09:01:20 +00:00
// Get the size of the list.
2023-12-16 10:08:17 +00:00
unsigned int list_sizeof(const List* head);
2023-11-29 09:01:20 +00:00
// Get the data of the node at the given ordinal number in the list.
List* list_get(List* head, unsigned int index);
2023-11-29 09:01:20 +00:00
// Delete the item in the list at the given ordinal location (1 is the first).
void list_remove(List** head, unsigned int index);
#endif