Algorithms_in_C++ 1.0.0
Set of 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.
|
inline |
Creates an empty CircularLinkedList.
|
inline |
Copy constructor for CircularLinkedList.
|
inlinenoexcept |
Move constructor for CircularLinkedList.
source | rvalue reference to a Circular Linked List |
|
inline |
|
inline |
Iteratively frees each node in the Circular Linked List from the heap
|
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 |
|
inline |
|
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
|
inlinenoexcept |
Move assignment operator.
other | rvalue reference to a Circular Linked List |
|
inline |
Copy assignment operator.
other | Reference to a Circular Linked List |
|
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
|
inline |
|
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
|
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
|
private |
Pointer to the last Node.