blob: 4e7831b2091861810811823cf3fbcfae06a753f7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#ifndef LIST_H
#define LIST_H
#include "common.h"
#define List_Foreach(listNode, list) for (ListNode* listNode = list->head; NULL != listNode ; listNode = listNode->next)
typedef struct ListNode {
struct ListNode* previous;
struct ListNode* next;
void* data;
} ListNode;
typedef struct List {
struct ListNode* head;
struct ListNode* tail;
} List;
List* List_Create();
void List_Clear(List* list);
void List_Destroy(List* list);
List* List_CreateClone(List* list);
BOOL List_IsEmpty(List* list);
void List_Append(List* list, void* data);
void List_Prepend(List* list, void* data);
ListNode* List_GetFirstNode(List* list);
ListNode* List_GetLastNode(List* list);
ListNode* List_FindFirstOccurrence(List* list, void* data);
int List_FindFirstOccurrenceIndex(List* list, void* data);
int List_GetCount(List* list);
void List_RemoveNode(List* list, ListNode* node);
void List_RemoveFirstNode(List* list);
void List_RemoveLastNode(List* list);
void List_RemoveFirstOccurrence(List* list, void* data);
typedef struct Stack {
List* list;
} Stack;
Stack* Stack_Create();
void Stack_Clear(Stack* stack);
void Stack_Destroy(Stack* stack);
BOOL Stack_IsEmpty(Stack* stack);
void Stack_Push(Stack* stack, void* data);
void* Stack_Pop(Stack* stack);
typedef struct Queue {
List* list;
} Queue;
Queue* Queue_Create();
void Queue_Clear(Queue* queue);
void Queue_Destroy(Queue* queue);
BOOL Queue_IsEmpty(Queue* queue);
void Queue_Enqueue(Queue* queue, void* data);
void* Queue_Dequeue(Queue* stack);
#endif // LIST_H
|