#include "deque.h" bool deque::addToDequeLeft(int id) { if(in_deque(id)) { return false; } l.insertHead(id); return true; } bool deque::addToDequeRight(int id) { if(in_deque(id)) { return false; } l.insertTail(id); return true; } int deque::removeFromDequeLeft() { int id = l.at(l.size() - 1); l.remove(id); return true; } int deque::removeFromDequeRight() { int id = l.at(0); l.remove(id); return false; } int deque::showTopOfDequeLeft() { if(l.size() == 0) { return -1; } int left = l.at(l.size() - 1); return left; } int deque::showTopOfDequeRight() { if(l.size() == 0) { return -1; } int right = l.at(0); return right; } int deque::showSizeOfDeque() { return l.size(); } bool deque::in_deque(int id) { node* node_ptr = l.head; while(node_ptr != NULL) { if(node_ptr->id == id) { return true; } node_ptr = node_ptr->next; } return false; }