Created
August 13, 2016 17:52
-
-
Save Soulstorm50/9163640d6d85680ea4a772a481e9cc0a to your computer and use it in GitHub Desktop.
Deque.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include"DoubleLinkedList.h" | |
using namespace std; | |
class Deque | |
{ | |
DoubleLinkedList d; | |
uint counter = 0; | |
public: | |
Deque() | |
{ | |
counter = 0; | |
} | |
~Deque() | |
{ | |
Clear(); | |
} | |
bool IsEmpty() | |
{ | |
return counter == 0; | |
} | |
void Clear() | |
{ | |
if (!IsEmpty()) | |
{ | |
d.ClearList(); | |
counter = 0; | |
} | |
} | |
void PushBack(int prime, char* data) | |
{ | |
d.AddTail(prime,data); | |
counter++; | |
} | |
void PushFront(int prime, char* data) | |
{ | |
d.AddHead(prime, data); | |
counter++; | |
} | |
void PushByPriority(int prime, char* data) | |
{ | |
d.AddData(prime, data); | |
} | |
void PopBack() | |
{ | |
if (!IsEmpty()) | |
{ | |
d.GetDataFromTail(counter); | |
d.RemoveTail(); | |
counter--; | |
} | |
} | |
void PopFront() | |
{ | |
if (!IsEmpty()) | |
{ | |
d.GetDataFromHead(0); | |
d.RemoveHead(); | |
counter--; | |
} | |
} | |
void PrintDeque() | |
{ | |
d.PrintList(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment