Program Listing for File deque_with_linked_list.h

Return to documentation for file (data_structures/deque_with_linked_list.h)

#ifndef DATA_STRUCTURES_DEQUE_WITH_LINKED_LIST_H
#define DATA_STRUCTURES_DEQUE_WITH_LINKED_LIST_H

#include "doubly_linked_list.h"

namespace DataStructures {

template <typename T>
class DequeWithLinkedList {
public:
        void add_first(const T& element) { list.add_first(element); }

        void add_last(const T& element) { list.add_last(element); }

        T del_first()
        {
                T front_element = list.get_first();
                list.del_first();
                return front_element;
        }

        T del_last()
        {
                T back_element = list.get_last();
                list.del_last();
                return back_element;
        }

        T peek_first() const { return list.get_first(); }

        T peek_last() const { return list.get_last(); }

private:
        DoublyLinkedList<T> list;
};

} // namespace DataStructures

#endif // DATA_STRUCTURES_DEQUE_WITH_LINKED_LIST_H