class ArrayDeque<E>
Class ArrayDeque<E>
stores a double-ended queue (deque) of elements of type E
, implemented with a dynamic array as internal storage. A deque can be used in place of a stack or queue. ArrayDeque<E>
is optimized for adding and removing from both the front and the back of the deque but does not provide the arbitrary access to elements that a general list data structure would.
Modifiers | Return Types | Method and Description |
---|---|---|
public |
() |
create() |
Modifiers | Return Types | Method and Description |
---|---|---|
public |
() |
destroy() |
Modifiers | Return Types | Method and Description |
---|---|---|
public |
(ArrayDeque<E>) |
addFirst(E element) Adds an element to the beginning of the deque. |
public |
(ArrayDeque<E>) |
addLast(E element) Adds an element to the end of the deque. |
public |
(ArrayDeque<E>) |
clear() Removes all elements from the deque. |
public readonly |
(ArrayDeque<E>) |
copy(AddressMap addresses) |
public readonly |
(E) |
getFirst() Gets the element at the beginning of the deque. |
public readonly |
(E) |
getLast() Gets the element at the end of the deque. |
public readonly |
(boolean) |
isEmpty() Checks whether or not the deque is empty. |
public readonly |
(Iterator<E>) |
iterator() Creates an iterator to iterate over all the values in the deque. |
public |
(E) |
removeFirst() Removes the element at the beginning of the deque. |
public |
(E) |
removeLast() Removes the element from the end of the deque. |
public readonly |
(String) |
toString() Produces a |
Modifiers | Return Types | Method and Description |
---|---|---|
public readonly get |
(int) |
size() |
public readonly get locked |
(long) |
sizeLong() Gets size of the deque. |
public create() => ()
public destroy() => ()
public addFirst(E element) => (ArrayDeque<E>)
Adds an element to the beginning of the deque. This operation is constant time in the best case and amortized constant time in the worst case, which occurs when deque storage is full and a linear-time array resize must be performed.
element
- element to be added
deque after the element is added
public addLast(E element) => (ArrayDeque<E>)
Adds an element to the end of the deque. This operation is constant time in the best case and amortized constant time in the worst case, which occurs when deque storage is full and a linear-time array resize must be performed.
element
- element to be added
deque after the element is added
public clear() => (ArrayDeque<E>)
Removes all elements from the deque. This operation is constant time.
deque after being cleared
public readonly copy(AddressMap addresses) => (ArrayDeque<E>)
public readonly getFirst() => (E)
Gets the element at the beginning of the deque. This operation is constant time.
first element in the deque
NoSuchElementException
- if the deque is empty
public readonly getLast() => (E)
Gets the element at the end of the deque. This operation is constant time.
last element in the deque
NoSuchElementException
- if the deque is empty
public readonly isEmpty() => (boolean)
Checks whether or not the deque is empty.
true
if the deque is empty
public readonly iterator() => (Iterator<E>)
Creates an iterator to iterate over all the values in the deque.
iterator
public removeFirst() => (E)
Removes the element at the beginning of the deque. This operation is constant time.
element being removed
NoSuchElementException
- if the deque is empty
public removeLast() => (E)
Removes the element from the end of the deque. This operation is constant time.
element being removed
NoSuchElementException
- if the deque is empty
public readonly toString() => (String)
Produces a String
representation of the deque, listing all elements in order.
String
representation