20 std::shared_ptr<Node<NType>>
next =
nullptr;
63 std::shared_ptr<Node<T>> newNode = std::make_shared<Node<T>>();
64 newNode->data = value;
65 newNode->next =
nullptr;
92 while (temp->
next !=
nullptr) {
93 temp = temp->
next.get();
103 if (
theFirst ==
nullptr)
throw std::runtime_error(
"cannot dequeue empty queue");
121 virtual size_t size() {
125 temp = temp->next.get();
150 std::cout <<
"The first in the queue right now is " << deez.
front_element() << std::endl;
152 std::cout <<
"The first has been popped!" << std::endl;
This is a template class that represents a single element of a queue, and it will be called "Node".
Definition queue_dsa.hpp:17
std::shared_ptr< Node< NType > > next
Stores the address of the next node.
Definition queue_dsa.hpp:20
NType data
Stores the data for each node.
Definition queue_dsa.hpp:19
Node()=default
Default Constructor.
This is a template class that represents the queue data structure.
Definition queue_dsa.hpp:11
virtual T last_element()
Prints out the last element in the queue.
Definition queue_dsa.hpp:90
virtual T popFront()
Removes the first element in the queue.
Definition queue_dsa.hpp:102
MyQueue(const MyQueue< T > &)=delete
Deleted copy constructor.
virtual T front_element()
Prints out the front element in the queue.
Definition queue_dsa.hpp:83
std::shared_ptr< Node< T > > theRear
Pointer to the last element of the queue.
Definition queue_dsa.hpp:29
virtual MyQueue< T > & push_back(const T &value)
Inserts a value at the end of the queue.
Definition queue_dsa.hpp:62
MyQueue & operator=(const MyQueue< T > &)=delete
Deleted copy assignment operator.
MyQueue & operator=(MyQueue< T > &&other)=default
Default Move assignment operator.
std::shared_ptr< Node< T > > theFirst
Pointer to the first element of the queue.
Definition queue_dsa.hpp:28
MyQueue()=default
Default Constructor.
virtual bool isEmpty()
Returns true if the queue is empty.
Definition queue_dsa.hpp:114
MyQueue(MyQueue< T > &&other)=default
Default Move constructor.