From charlesreid1

Notes

array-based deque (double-ended queue) object.

implementation details:

  • floating head/tail index variables and dynamic resizing
  • dynamic moving also required - if head floats too far.
  • variable or fixed size.

code

Link to the code on git.charlesreid1.com: https://git.charlesreid1.com/cs/java/src/master/stacks-queues-deques/queues/ArrayDeque.java

interface

The methods implemented for a deque object are:

  • size() - get the number of elements in the queue
  • isEmpty() - returns true if queue is empty
  • first() - return reference to front, but don't remove
  • last() - return reference to back, but don't remove
  • addFront() - add new item to front of queue
  • addBack() - add new item to back of queue
  • removeFront() - remove item from front of queue
  • removeBack() - remove item from back of queue

Flags