Deque
A simple double-linked queue abstraction, backed by linked list.
Deque type
queue< Type >
Subtypes | Supertypes | Comparable types |
---|---|---|
| sequence< Type > | java.util.Deque<Type> |
Deque creation
new linkedlist
Parameter type | Result type |
---|---|
Type... | deque< Type > |
Creates an empty deque. Optionally, initial values may be specified right in the new linked list creation expression.
deque<string> test = new linkedlist<string> {"A", "B", "C"};
Alternatively, a sequence may be specified that is used to copy elements from.
deque<Type> = new linkedlist<Type> (sequence);
Operations on deque
iterator
Operand type | Parameter type | Result type |
---|---|---|
sequence< Type > | none | modifying_iterator< Type > |
This operation is redefined for deque to return a modifying_iterator
.
addFirst / push
Operand type | Parameter type | Result type |
---|---|---|
deque< Type > | Type | Type |
Appends an element to the head of the deque.
set.addFirst (value);
addLast
Operand type | Parameter type | Result type |
---|---|---|
deque< Type > | Type | Type |
Appends an element to the tail of the deque.
set.addLast (value);
removeFirst / pop
Operand type | Parameter type | Result type |
---|---|---|
deque< Type > |
| Type |
Removes an element from the head of the deque.
set.removeFirst (value);
first
Operand type | Parameter type | Result type |
---|---|---|
queue< Type > |
| Type |
Retrieves the first element at the head of the deque without removing it.
set.first ();
last
Operand type | Parameter type | Result type |
---|---|---|
queue< Type > |
| Type |
Retrieves the first element at the tail of the deque without removing it.
set.first ();