Deque

A deque (pronounced "deck") is a double-ended queue, hence its name. A deque is like a queue, except that elements can also be inserted at the head of the queue, not just at the end. This also makes it possible to use it like a stack.

The deque is new as of Java 6, and Sun/Oracle recommends to use the deque for all queue and stack implementations, and the queue and stack from Java 5 have become deprecated. The deque also contains the stack, as elements can be inserted at the head of the queue, and it provides the familiar stack functions for popping and pushing as well.

The deque is used internally in the JavaTools function JMooreBellmann[], which is an implementation of the D'Esopo Pape variant of the Moore-Bellmann algorithm to solve the minimum cost path problem from a source node to all other nodes, permitting negative arc lenghts in a network without negative cycles. The D'Esopo Pape variant is the fastest method for the Moore-Bellmann algorithm known today, and it depends on a deque for the node labelling.

In JavaTools the functions for the deque are the same as for the queue  (see there), with the following additions:

"deque_1.gif"

same as JDequePoll[]

"deque_2.gif"

"deque_3.gif"

same as JDequePeek[]

"deque_4.gif"

"deque_5.gif"

"deque_6.gif"

same as JDequeOffer[]

"deque_7.gif"

"deque_8.gif"

same as JDequeAdd[]

"deque_9.gif"

same as JDequeGet[]

"deque_10.gif"

"deque_11.gif"

can be used to model a stack.

"deque_12.gif"

can be used to model a stack.

"deque_13.gif"

same as JDequeRemove[]

"deque_14.gif"

"deque_15.gif"

removes the element of the first occurrence of a specified element

"deque_16.gif"

removes the element of the last occurrence of a specified element

Spikey Created with Wolfram Mathematica 7.0