![]() |
TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
A class that implements a Circular Linked List. More...
Public Member Functions | |
CircularLinkedList () | |
Creates an empty CircularLinkedList. | |
CircularLinkedList (const CircularLinkedList ©) | |
Copy constructor for CircularLinkedList. | |
CircularLinkedList (CircularLinkedList &&source) noexcept | |
Move constructor for CircularLinkedList. | |
CircularLinkedList & | operator= (const CircularLinkedList &other) |
Copy assignment operator. | |
CircularLinkedList & | operator= (CircularLinkedList &&other) noexcept |
Move assignment operator. | |
~CircularLinkedList () | |
Cleans up memory when destroyed. | |
void | erase () |
void | insert (const std::vector< int64_t > &values) |
Inserts all the values from a vector into the Circular Linked List. | |
void | insert (int64_t data) |
Inserts a single value into the Circular Linked List. | |
void | insert (Node *node) |
Inserts a given Node into the Circular Linked List. | |
void | print () |
Prints the values of the Circular Linked List, beginning from the root Node. | |
void | print (Node *root) |
Prints the values of the Circular Linked List, beginning from a given Node to be used as the root. | |
std::vector< int64_t > | values () |
Returns a std::vector of the values of the Circular Linked List. | |
std::vector< int64_t > | values (Node *root) |
Returns a std::vector of the values of the Circular Linked List, beginning from a given Node. | |
Private Attributes | |
Node * | root |
Pointer to the root Node. | |
Node * | end {} |
Pointer to the last Node. | |
A class that implements a Circular Linked List.
Definition at line 57 of file circular_linked_list.cpp.
|
inline |
Creates an empty CircularLinkedList.
Definition at line 66 of file circular_linked_list.cpp.
|
inline |
Copy constructor for CircularLinkedList.
Definition at line 73 of file circular_linked_list.cpp.
|
inlinenoexcept |
Move constructor for CircularLinkedList.
source | rvalue reference to a Circular Linked List |
Definition at line 86 of file circular_linked_list.cpp.
|
inline |
Cleans up memory when destroyed.
Definition at line 122 of file circular_linked_list.cpp.
|
inline |
Iteratively frees each node in the Circular Linked List from the heap
Definition at line 126 of file circular_linked_list.cpp.
|
inline |
Inserts all the values from a vector into the Circular Linked List.
Goes through each element in the vector sequentially, inserting it into the list
values | The vector of integer values that is to be inserted |
Definition at line 146 of file circular_linked_list.cpp.
|
inline |
Inserts a single value into the Circular Linked List.
Creates a Node with the given value, pointing to the root Node and inserts it into the list
data | The integer valus to be inserted |
Definition at line 158 of file circular_linked_list.cpp.
|
inline |
Inserts a given Node into the Circular Linked List.
Checks wheter the list is empty, and inserts the Node, modifying the end pointer
node | The Node that is to be inserted |
< Set node as the root
< Point node to itself
< Set the end to the root
< Append node to the end
< Set the next value to the root
< Make end point to node
Definition at line 169 of file circular_linked_list.cpp.
|
inlinenoexcept |
Move assignment operator.
other | rvalue reference to a Circular Linked List |
Definition at line 112 of file circular_linked_list.cpp.
|
inline |
Copy assignment operator.
other | Reference to a Circular Linked List |
Definition at line 97 of file circular_linked_list.cpp.
|
inline |
Prints the values of the Circular Linked List, beginning from the root Node.
Goes through each Node from the root and prints them out in order
Definition at line 187 of file circular_linked_list.cpp.
|
inline |
Prints the values of the Circular Linked List, beginning from a given Node to be used as the root.
Goes through each Node from the given Node and prints them out in order. If the list is empty, it prints the message 'Empty List!'
root | The Node to start at |
Definition at line 196 of file circular_linked_list.cpp.
|
inline |
Returns a std::vector of the values of the Circular Linked List.
Starting from the root Node, appends each value of the list to a std::vector and returns it
Definition at line 214 of file circular_linked_list.cpp.
|
inline |
Returns a std::vector of the values of the Circular Linked List, beginning from a given Node.
Starting from a given Node, appends each value of the list to a std::vector and returns it
root | The Node to start at |
< Return empty vector
Definition at line 223 of file circular_linked_list.cpp.
|
private |
|
private |
Pointer to the root Node.
Definition at line 59 of file circular_linked_list.cpp.