interface Deque<E>
Interface Deque<E>
defines the operations that a container class must implement to be a double-ended queue (deque). A deque can be used in place of a stack or queue. A deque should be optimized for adding and removing from both the front and the back but does not necessarily provide arbitrary access to elements like classes that have the List<E>
interface.
Modifiers | Return Types | Method and Description |
---|---|---|
public |
(Deque<E>) |
addFirst(E element) Method should add an element to the beginning of the deque. |
public |
(Deque<E>) |
addLast(E element) Method should add an element to the end of the deque. |
public |
(Deque<E>) |
clear() Removes all elements from the deque. |
public readonly |
(E) |
getFirst() Method should retrieve the element at the beginning of the deque. |
public readonly |
(E) |
getLast() Method should retrieve the element at the end of the deque. |
public readonly |
(boolean) |
isEmpty() Method should check whether or not the deque is empty. |
public |
(E) |
removeFirst() Method should remove the element at the beginning of the deque. |
public |
(E) |
removeLast() Method should remove the element at the end of the deque. |
Modifiers | Return Types | Method and Description |
---|---|---|
public readonly get |
(int) |
size() Property should get the number of elements in the deque. |
public addFirst(E element) => (Deque<E>)
Method should add an element to the beginning of the deque. Ideally, this operation should run in constant or amortized constant time.
element
- element to add
deque after the add
public addLast(E element) => (Deque<E>)
Method should add an element to the end of the deque. Ideally, this operation should run in constant or amortized constant time.
element
- element to add
deque after the add
public clear() => (Deque<E>)
Removes all elements from the deque. This operation should run in constant time.
deque after being cleared
public readonly getFirst() => (E)
Method should retrieve the element at the beginning of the deque. This operation should run in constant time.
first element in the deque
public readonly getLast() => (E)
Method should retrieve the element at the end of the deque. This operation should run in constant time.
last element in the deque
public readonly isEmpty() => (boolean)
Method should check whether or not the deque is empty.
true
if the deque is empty
public removeFirst() => (E)
Method should remove the element at the beginning of the deque. This operation should run in constant time.
element being removed
public removeLast() => (E)
Method should remove the element at the end of the deque. This operation should run in constant time.
element being removed
public readonly get size() => (int)
Property should get the number of elements in the deque.
size of the deque