-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinked-List-Int.h
More file actions
61 lines (50 loc) · 2.9 KB
/
Linked-List-Int.h
File metadata and controls
61 lines (50 loc) · 2.9 KB
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
struct ListNodeInt
{
int value;
struct ListNodeInt *next;
};
typedef struct ListNodeInt ListNodeInt;
/// @brief Prints the values of the list.
/// @param list The pointer to the first node of the list.
void listIntPrint(ListNodeInt* list);
/// @brief Adds provided value in the list.
/// @param list The pointer to the first node of the list.
/// @param value The value to be added at the end of the list.
/// @return The address of the first node of the list.
ListNodeInt* listIntAdd(ListNodeInt* list, int value);
/// @brief Adds provided value in the list so that it remains sorted.
/// @param list The pointer to the first node of the list.
/// @param value The value to be added in the list.
/// @return The address of the first node of the list.
ListNodeInt* listIntAddSorted(ListNodeInt* list, int value);
/// @brief Updates value at given index in list.
/// @param list The pointer to the frist node of the list.
/// @param index The index of the node to have value updated.
/// @param oldValue The value that is currently in that node.
/// @param newValue The value that will replace the old one.
/// @return The address of the first node of the list or NULL if operation could not be completed.
ListNodeInt* listIntUpdate(ListNodeInt* list, int index, int oldValue, int newValue);
/// @brief Removes first occurence of the provided value from the list, if it is present.
/// @param list The pointer to the first node of the list.
/// @param value The value to be removed from the list.
/// @return The address of the first node of the list or NULL if list is empty.
ListNodeInt* listIntRemove(ListNodeInt* list, int value);
/// @brief Finds the provided value in the list, if it is present.
/// @param list The pointer to the first node of the list.
/// @param value The value to be found in the list.
/// @return The address of the node that contains the value provided or NULL if the value doen not exist in list.
ListNodeInt* listIntFind(ListNodeInt* list, int value);
/// @brief A function to get the last node of the list.
/// @param list The pointer to the first node of the list.
/// @return The last node of the list or NULL if list is empty(NULL).
ListNodeInt* getLastIntNode(ListNodeInt* list);
/// @brief A function to get the node at specified index in the list.
/// @param list The pointer to the first node of the list.
/// @param index The index of the wanted node.
/// @return The node at the specified index, or NULL if list is empty or index is out of bounds.
ListNodeInt* getIndexIntNode(ListNodeInt* list, int index);
/// @brief A function to get the index of a node that would contain the given value if added sorted in the current list.
/// @param list The pointer to the first node of the list.
/// @param value The value to be used.
/// @return (Index of the node after which the value should be inserted) + 1 = Index at which the value should be inserted.
int getSortedIndexOfValue(ListNodeInt* list, int value);