21 std::unique_ptr<Node<NType>>
next =
nullptr;
29 std::unique_ptr<Node<LLType>> head;
71 std::unique_ptr<Node<LLType>> newNode = std::make_unique<Node<LLType>>();
72 newNode->data = value;
73 newNode->next = std::move(head);
75 head = std::move(newNode);
84 std::unique_ptr<Node<LLType>> newNode = std::make_unique<Node<LLType>>();
85 newNode->data = value;
86 newNode->next =
nullptr;
89 head = std::move(newNode);
94 while (lastNode->
next !=
nullptr) {
95 lastNode = lastNode->
next.get();
97 lastNode->
next = std::move(newNode);
106 if (!obj.head)
return (os <<
"[ ]");
109 while (PRINT_node->
next !=
nullptr) {
110 std::cout << PRINT_node->
data <<
", ";
111 PRINT_node = PRINT_node->
next.get();
113 os << PRINT_node->
data;
114 PRINT_node = PRINT_node->
next.get();
This is a template class represents a single element of the linked list, and it will be called "Node"...
Definition linkedlist.hpp:18
std::unique_ptr< Node< NType > > next
Stores the address of the next node.
Definition linkedlist.hpp:21
Node()=default
Default Constructor.
NType data
Stores the data for each node.
Definition linkedlist.hpp:20
This is a template class that represents the linked list.
Definition linkedlist.hpp:12
virtual LinkedList & insertAtFront(const LLType &value)
Inserts a value at the front of the linked list.
Definition linkedlist.hpp:70
LinkedList(LinkedList< LLType > &&other) noexcept=default
Default Move constructor.
virtual LinkedList< LLType > & operator=(LinkedList< LLType > &&other) noexcept=default
Move assignment operator.
friend std::ostream & operator<<(std::ostream &os, const LinkedList< LLType > &obj)
Outputs the values in the linked list.
Definition linkedlist.hpp:104
LinkedList()=default
Default Constructor.
virtual LinkedList< LLType > & operator=(const LinkedList< LLType > &)=delete
Default Copy assignment operator Prevents assigning the values of existing LinkedList<T> objects to o...
LinkedList(const LinkedList< LLType > &)=delete
Deleted copy constructor.
virtual LinkedList & insertAtEnd(const LLType &value)
Inserts a value at the end of the linked list.
Definition linkedlist.hpp:83
virtual ~LinkedList()=default
Default Destructor.