The methods defined from the Deque API page in QQKachoo are as follows.
size()
- returns length of the queue, needed forisEmpty()
addFirst()
- adds value to the front of the queueaddLast()
- adds value to the end of the queuepeekFirst()
- returns the value at the front of the queuepeekLast()
- returns the value at the end of the queueremoveFirst()
- removes the first element of the queue and returns itremoveLast()
- removes the last element of the queue and returns itremoveFirstOccurrence()
- removes the first occurrence of the value in the queue from the front. If not found, returnnull
removeLastOccurrence()
- removes the last of occurrence of the value in the queue from the front. If not found, returnnull
Iterator()
- iterate through the queuepoll()
- safely removes the first element in the queue. If there are no elements remaining, returnnull
pollFirst()
- safely remove the first element in the queue. If there are no elements remaining, returnnull
offerFirst()
- safely add the value to the front of the queue. If it violates anything, returnfalse
, else, returntrue
offerLast()
- safely add the value to the end of the queue. If it violates anything, returnfalse
, else, returntrue
contains()
- iterate through the queue to check if the value is in the queue. If found, returntrue
, else returnfalse
Note that the implementation of the methods may not reflect the order that they were placed in in the README
See Projects tab for to-do list and details
A doubly linked node-based architecture was implemented because it allows easy trasversal between nodes, and saves both time and memory by having both a front an end modifiable in constant time.
The various elements explored in this repo stems from the Deque class available in the Java API. The methods are developed through a bottom-up approach where the most basic of the methods are added and revised by a team of three.
4 steps of maintaining runnability (To-do list):
- Maintain runnability
- Implement basic methods as listed above
- Generic type Interface and class
- Implement Iterator in Deque
Kevin Wang (GitHub profile of Kevin Wang)
Peter Cwalina (GitHub profile of Peter Cwalina)
Ahnaf Hasan (GitHub profile of Ahnaf Hasan)