Fetching a value from a Deque

The implementation of the Front() and IsEmpty() operations for the Deque data type is the same as the implementation of the Front() and IsEmpty() operations for the Queue data type. For the Back() operation, it just returns the value of the m_back node. The implementation should be as follows:

template <typename T>T Deque<T>::Back(){    // Just return the value    // of m_back node    return m_back->Value;}

Since the implementation of this operation doesn't depend on the number of Deque elements, the complexity of this operation is O(1) for both best and worst case.

Get C++ Data Structures and Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.