April 2018
Intermediate to advanced
322 pages
6h 57m
English
There are two ways to enqueue a new element into the Deque data type—from the front side and from the back side. To enqueue a new element from the front side, we can use the EnqueueFront() operation, which will create a new DoublyNode node and then assigns the Next pointer of this new node to the current m_front node. Also, if the current m_front exists, the Previous pointer of the current m_front node points to the new node. Now, the m_front node will change to the new node. If it's the only node that resides in the Deque data type, the m_back node will also point to this new node. The implementation of the EnqueueFront() operation should be as follows:
template <typename T>void Deque<T>::EnqueueFront(T ...