public final class IntDeque
extends java.lang.Object
Deque| Constructor and Description |
|---|
IntDeque()
Creates a new IntDeque with an initial capacity of 4.
|
IntDeque(int initialCapacity)
Creates a new IntDeque with the specified initial capacity.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFirst(int element)
Inserts an element before the head of this deque.
|
void |
addLast(int element)
Inserts an element at the tail of this deque.
|
void |
clear()
Clears this deque.
|
void |
compact()
Compacts this deque, minimizing its size in memory.
|
int |
get(int index)
Gets the element at the specified index of this deque, without removing it.
|
int |
getFirst()
Gets the first element (head) of this deque without removing it.
|
int |
getLast()
Gets the last element of this deque without removing it.
|
boolean |
isEmpty() |
int |
removeFirst()
Retrieves and removes the first element (head) of this deque.
|
int |
removeLast()
Retrieves and removes the last element of this deque.
|
int |
size() |
public IntDeque()
public IntDeque(int initialCapacity)
initialCapacity - the initial capacity, strictly positivepublic void clear()
public boolean isEmpty()
public int size()
public void compact()
public void addFirst(int element)
element - the element to addpublic void addLast(int element)
element - the element to addpublic int get(int index)
The index is relative to the head: the first element is at index 0, the next element is at index 1, etc.
index - the index of the element, relative to the headjava.util.NoSuchElementException - if the deque contains less than index+1 elementspublic int getFirst()
java.util.NoSuchElementException - if the deque is emptypublic int getLast()
java.util.NoSuchElementException - if the deque is emptypublic int removeFirst()
java.util.NoSuchElementException - if the deque is emptypublic int removeLast()
java.util.NoSuchElementException - if the deque is empty