-
Notifications
You must be signed in to change notification settings - Fork 0
/
LinkedList.h
105 lines (86 loc) · 2.55 KB
/
LinkedList.h
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* COMP2521 - Data Structures and Algorithms
* Assignment 2 - Simple Search Engines
*
* Group: TwoBrothers
*
* Partners: Kurt Banwell-Pachernegg (Z5022859)
* Sam Eager (Z3414861)
*/
#ifndef LINKED_LIST_H
#define LINKED_LIST_H
typedef struct LinkedList * LinkedList;
LinkedList newLinkedList();
/**
* Adds a value to the end of the list
(is an alias for addToEndOfLinkedList()).
*/
void addToLinkedList(LinkedList list, void * value);
/**
* Adds a value to the front of the list.
*/
void addToFrontOfLinkedList(LinkedList list, void * value);
/**
* Adds a value to the end of the list.
*/
void addToEndOfLinkedList(LinkedList list, void * value);
/**
* Adds a value to a specified index in the list, moving the value that
* is currently at that index to the right.
*
* @returns int Returns 1 if successful, 0 if the pos is invalid (i.e the
* position is less that zero or greater that the size of the list).
*/
int insertIntoLinkedList(LinkedList list, int pos, void * value);
/**
* Removes the value at the front of the list and returns it.
*/
void * removeFirstFromLinkedList(LinkedList list);
/**
* Removes the value from the end of the list and returns it.
*/
void * removeLastFromLinkedList(LinkedList list);
/**
* Removes the value from the list that matches the value given and
* returns it.
*/
void * removeFromLinkedList(LinkedList list, void * value);
/**
* Removes the value from the corresponding pos (index) and returns it.
*/
void * spliceLinkedList(LinkedList list, int pos);
/**
* Wether or not a given value is in the list.
*
* @returns int Returns 1 if the value exists, or 0 otherwise.
*/
int isInLinkedList(LinkedList list, void * value);
/**
* Gets the first value from the list without removing it and returns it.
*/
void * getFirstFromLinkedList(LinkedList list);
/**
* Gets the last value from the list withut removing it and returns it.
*/
void * getLastFromLinkedList(LinkedList list);
/**
* Gets the value corresponding to the given pos (index) without
* removing it and returns it.
*/
void * getFromLinkedList(LinkedList list, int pos);
/**
* Returns the number of values currently stored in the list.
*/
int sizeOfLinkedList(LinkedList list);
/**
* Whether or not the list contains any values.
*
* @returns int Returns 1 if the list contains at least one value, or 0
* otherwise.
*/
int isEmptyLinkedList(LinkedList list);
/**
* Prints the list to standard output, convering all of the values to (int).
*/
void printLinkedList(LinkedList list);
#endif