1
- # cpp-linked-lists
2
- My implementation of linked-lists in c++
1
+ # C++ Linked Lists
2
+ My implementation of doubley-linked lists in C++
3
+ ## NOTE:
4
+ This library is best used when you need a dynamicly sized list, and staticly sized arrays are not an option.
5
+ So don't go too crazy with this code. It's always best to try and find a work-around solution before relying
6
+ on linked-lists to bail you out.
7
+
3
8
## How it works
4
9
Within the ` List ` class, first we define list-node type we call ` node ` .
5
10
```
@@ -15,3 +20,25 @@ Each node contains placholders for the data(integer), the next list-node, and th
15
20
A list-head is then initialized with the ` list() ` method. The list head is the start of the list. This creates a list
16
21
head with the ` data ` field set to 0, and ` next ` and ` prev ` fields set to NULL. This node is not used when accessing the list,
17
22
it's just used to initialize the list.
23
+ This allows you to chain many list-nodes together, making a doubley-linked list.
24
+
25
+
26
+ ## How to use this library
27
+
28
+ ### Create a List object:
29
+ ` List myList; // Creates an empty List object. `
30
+
31
+ ### Methods:
32
+ ``` c++
33
+ myList.append(54 ); // Appends 54 to list.
34
+
35
+ myList.remel(1 ); // Returns and removes the element at index 1(or provided index)
36
+
37
+ myList.print(); // Prints items in the list.
38
+
39
+ myList.index(7 ); // Returns the element at index 7(or provided index)
40
+
41
+ // Removes all the elements from the first provided index, and to the last index, including the elements at the provided indices
42
+ // When removed multiple items at once, this is MUCH faster than using a for-loop and remel.
43
+ myList.slice(9 , 18 );
44
+ ```
0 commit comments