C Workshop
LinkedList.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stdlib.h>
4 
6 
7 typedef int ListDataType;
8 
9 typedef struct Node_t Node;
10 
11 typedef struct List_t List;
12 
13 struct Node_t
14 {
17 };
18 
19 struct List_t
20 {
22 };
23 
29 List *CreateList();
30 
36 void FreeList(List *list);
37 
44 size_t GetListSize(List *list);
45 
52 Node *GetListHead(List *list);
53 
60 Node *GetNextNode(Node *currentNode);
61 
69 
77 Node *Insert(Node *after, ListDataType newValue);
78 
86 Node *PushFront(List *list, ListDataType newValue);
87 
95 Node *PushBack(List *list, ListDataType newValue);
96 
103 ListDataType PopFront(List *list);
104 
111 ListDataType PopBack(List *list);
112 
119 void DeleteNode(List *list, Node *target);
120 
128 Node *DeleteValue(List *list, ListDataType value);
129 
137 Node *Find(List *list, ListDataType value);
List * CreateList()
Create a List object.
Definition: LinkedList.c:4
ListDataType PopBack(List *list)
Removes the node from the end of the list.
Definition: LinkedList.c:140
Node * GetListHead(List *list)
Get the list's head.
Definition: LinkedList.c:49
ListDataType PopFront(List *list)
Removes the node from the front of the list.
Definition: LinkedList.c:118
Node * GetNextNode(Node *currentNode)
Get the next node for the given node.
Definition: LinkedList.c:54
ListDataType GetValue(Node *node)
Get the value of the Node.
Definition: LinkedList.c:59
void FreeList(List *list)
Free all memory allocated for the list.
Definition: LinkedList.c:18
Node * Insert(Node *after, ListDataType newValue)
Inserts a new node after the given node.
Definition: LinkedList.c:64
size_t GetListSize(List *list)
Get the size of the list.
Definition: LinkedList.c:37
int ListDataType
Definition: LinkedList.h:7
Node * PushFront(List *list, ListDataType newValue)
Appends a new node to the head of the list.
Definition: LinkedList.c:80
Node * Find(List *list, ListDataType value)
Finds the first node with the given value.
Definition: LinkedList.c:224
Node * PushBack(List *list, ListDataType newValue)
Append a new node to the end of the list.
Definition: LinkedList.c:96
void DeleteNode(List *list, Node *target)
Delete node from list given node.
Definition: LinkedList.c:166
Node * DeleteValue(List *list, ListDataType value)
Deletes a node from the list given the value.
Definition: LinkedList.c:192
Definition: LinkedList.h:20
Node * head
Definition: LinkedList.h:21
Definition: LinkedList.h:14
Node * next
Definition: LinkedList.h:16
ListDataType data
Definition: LinkedList.h:15