E
- the type of element stored in the dequepublic abstract class AbstractDeque<E> extends AbstractQueue<E> implements Deque<E>
Deque
interface. Deques provide a very
broad API, including the operations of both a FIFO queue, and a LIFO stack, in addition to the
numerous operations that work on either head or tail. Most of these methods are aliases for other
methods (for readability in specific use cases), so this base class implements them to delegate
to the appropriate method.
Sub-classes need only provide the handful of core operations without the boiler-plate of implementing these other alias methods.
Constructor and Description |
---|
AbstractDeque() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E e) |
void |
addFirst(E e) |
void |
addLast(E e) |
E |
element() |
E |
getFirst() |
E |
getLast() |
boolean |
offer(E e) |
E |
peek() |
E |
poll() |
E |
pop() |
void |
push(E e) |
E |
remove() |
boolean |
remove(Object o) |
E |
removeFirst() |
boolean |
removeFirstOccurrence(Object o) |
E |
removeLast() |
boolean |
removeLastOccurrence(Object o) |
addAll, clear
contains, containsAll, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
contains, descendingIterator, iterator, offerFirst, offerLast, peekFirst, peekLast, pollFirst, pollLast, size
addAll, clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray
public boolean add(E e)
This implementation delegates to addLast(Object)
and always returns true.
public E remove()
public E removeFirst()
removeFirst
in interface Deque<E>
public E removeLast()
removeLast
in interface Deque<E>
public E element()
public boolean remove(Object o)
remove
in interface Collection<E>
remove
in interface Deque<E>
remove
in class AbstractCollection<E>
public boolean removeFirstOccurrence(Object o)
removeFirstOccurrence
in interface Deque<E>
public boolean removeLastOccurrence(Object o)
removeLastOccurrence
in interface Deque<E>
public boolean offer(E e)
public E poll()
public E peek()