A deque (double-ended queue) is a generic data stucture which can be modified from either end, in contrast to both queues and stacks. A deque implementation may be extended to act as either of these other data structures by restricting certain operations. For example, a deque becomes a stack if it refuses to modify its beginning (shift and unshift).

Common operations are:

  • unshift - adds an item to the beginning.
  • shift - removes an item from the beginning.
  • push - adds an item to the end.
  • pop - removes an item from the end.

Less common operations are:

  • count - number of items. Rather easy to add in an implementation.
  • peek - retrieves the next item in the queue without removing it.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.