Interface LinkedDeque<E>
- Type Parameters:
E- the type of elements held in this collection
- All Superinterfaces:
Collection<E>, Deque<E>, Iterable<E>, Queue<E>, SequencedCollection<E>
- All Known Implementing Classes:
AbstractLinkedDeque, AccessOrderDeque, WriteOrderDeque
A linked list extension of the
Deque interface where the link pointers are tightly
integrated with the element. Linked deques have no capacity restrictions; they grow as necessary
to support usage. They are not thread-safe; in the absence of external synchronization, they do
not support concurrent access by multiple threads. Null elements are prohibited.
Most LinkedDeque operations run in constant time by assuming that the element parameter is associated with the deque instance. Any usage that violates this assumption will result in non-deterministic behavior.
An element can exist in only one instance of a deque implementation, but may exist in multiple implementations. Each implementation must define unique names for accessing and modifying its link pointers.
The iterators returned by this class are not fail-fast: If the deque is modified at any time after the iterator is created, the iterator will be in an unknown state. Thus, in the face of concurrent modification, the iterator risks arbitrary, non-deterministic behavior at an undetermined time in the future.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescription@Nullable ERetrieves the next element or null if either the element is unlinked or the last element on the deque.@Nullable EgetPrevious(E e) Retrieves the previous element or null if either the element is unlinked or the first element on the deque.booleanReturns if the element is at the front of the deque.booleanReturns if the element is at the back of the deque.iterator()voidmoveToBack(E e) Moves the element to the back of the deque so that it becomes the last element.voidmoveToFront(E e) Moves the element to the front of the deque so that it becomes the first element.voidSets the next element or null if there is no link.voidsetPrevious(E e, @Nullable E prev) Sets the previous element or null if there is no link.Methods inherited from interface Collection
clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArrayMethods inherited from interface Deque
add, addAll, addFirst, addLast, contains, element, getFirst, getLast, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, reversed, size
-
Method Details
-
isFirst
Returns if the element is at the front of the deque.- Parameters:
e- the linked element
-
isLast
Returns if the element is at the back of the deque.- Parameters:
e- the linked element
-
moveToFront
Moves the element to the front of the deque so that it becomes the first element.- Parameters:
e- the linked element
-
moveToBack
Moves the element to the back of the deque so that it becomes the last element.- Parameters:
e- the linked element
-
getPrevious
-
setPrevious
-
getNext
-
setNext
-
iterator
-
descendingIterator
LinkedDeque.PeekingIterator<E> descendingIterator()- Specified by:
descendingIteratorin interfaceDeque<E>
-