code

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:

Less common operations are: