Skip to content

Latest commit

 

History

History
62 lines (57 loc) · 2.33 KB

ArrayDeque.md

File metadata and controls

62 lines (57 loc) · 2.33 KB

ArrayDeque

Resizable-array implementation of the Deque interface. Null elements are prohibited. This class is likely to be faster than Stack when used as a stack, and faster than LinkedList when used as a queue.

Constructor

Constructor Description
ArrayDeque() Constructs an empty array deque with an initial capacity sufficient to hold 16 elements.
ArrayDeque(Collection<? extends E> c) Constructs a deque containing the elements of the specified collection, in the order they are returned by the collection's iterator.
StringBuilder(int initCapacity) Creates an empty string builder with the specified initial capacity.
ArrayDeque(int numElements) Constructs an empty array deque with an initial capacity sufficient to hold the specified number of elements.

Methods in ArrayDeque class

Method Description
public boolean offerFirst(E e) Inserts the specified element at the front of this deque.
public boolean offerLast(E e) Inserts the specified element at the end of this deque.
public E pollFirst() Retrieves and removes the first element of this deque, or returns null if this deque is empty.
public E pollLast() Retrieves and removes the last element of this deque, or returns null if this deque is empty.
public E peekFirst() Retrieves, but does not remove, the first element of this deque, or returns null if this deque is empty.
public E peekLast() Retrieves, but does not remove, the last element of this deque, or returns null if this deque is empty.
public int size() Returns the number of elements in this deque.
public boolean isEmpty() Returns true if this deque contains no elements.
public void clear() Removes all of the elements from this deque. The deque will be empty after this call returns.