2023-11-29 08:27:23 +00:00
|
|
|
#ifndef LIST_H_DEF
|
2023-11-29 09:01:20 +00:00
|
|
|
#define LIST_H_DEF
|
2023-11-29 08:27:23 +00:00
|
|
|
|
|
|
|
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.
|
2023-11-29 08:27:23 +00:00
|
|
|
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.
|
2023-11-29 08:27:23 +00:00
|
|
|
void* list_pop(List** head);
|
|
|
|
|
2023-11-29 09:01:20 +00:00
|
|
|
// Insert the data object to the beginning of the list.
|
2023-11-29 08:27:23 +00:00
|
|
|
void list_insert(List** head, void* data);
|
|
|
|
|
2023-11-29 09:01:20 +00:00
|
|
|
// Get the size of the list.
|
2023-11-29 08:27:23 +00:00
|
|
|
unsigned int list_sizeof(List* head);
|
|
|
|
|
2023-11-29 09:01:20 +00:00
|
|
|
// Get the data of the node at the given ordinal number in the list.
|
2023-11-29 08:27:23 +00:00
|
|
|
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).
|
2023-11-29 08:27:23 +00:00
|
|
|
void list_remove(List** head, unsigned int index);
|
|
|
|
|
|
|
|
#endif
|