Package org.miaixz.bus.core.center.queue
Class LinkedDeque<E extends Linked<E>>
java.lang.Object
java.util.AbstractCollection<E>
org.miaixz.bus.core.center.queue.LinkedDeque<E>
- Type Parameters:
E- the type of elements held in this collection
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Deque<E>,Queue<E>,SequencedCollection<E>
Linked list implementation 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 Linked parameter is associated with the deque instance. Any usage
that violates this assumption will result in non-deterministic behavior.
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.
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidvoidvoidclear()booleanelement()getFirst()getLast()booleanisEmpty()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.booleanbooleanofferFirst(E e) booleanpeek()peekLast()poll()pollLast()pop()voidremove()booleanbooleanremoveAll(Collection<?> c) booleanbooleanintsize()Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
containsAll, equals, hashCode, parallelStream, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
Constructor Details
-
LinkedDeque
public LinkedDeque()
-
-
Method Details
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<E extends Linked<E>>- Overrides:
isEmptyin classAbstractCollection<E extends Linked<E>>
-
size
public int size()Beware that, unlike in most collections, this method is NOT a constant-time operation.
-
clear
public void clear()- Specified by:
clearin interfaceCollection<E extends Linked<E>>- Overrides:
clearin classAbstractCollection<E extends Linked<E>>
-
contains
-
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
-
peek
-
peekFirst
-
peekLast
-
getFirst
-
getLast
-
element
-
offer
-
offerFirst
- Specified by:
offerFirstin interfaceDeque<E extends Linked<E>>
-
offerLast
-
add
-
addFirst
-
addLast
-
poll
-
pollFirst
-
pollLast
-
remove
-
remove
-
removeFirst
- Specified by:
removeFirstin interfaceDeque<E extends Linked<E>>- Specified by:
removeFirstin interfaceSequencedCollection<E extends Linked<E>>
-
removeFirstOccurrence
- Specified by:
removeFirstOccurrencein interfaceDeque<E extends Linked<E>>
-
removeLast
- Specified by:
removeLastin interfaceDeque<E extends Linked<E>>- Specified by:
removeLastin interfaceSequencedCollection<E extends Linked<E>>
-
removeLastOccurrence
- Specified by:
removeLastOccurrencein interfaceDeque<E extends Linked<E>>
-
removeAll
- Specified by:
removeAllin interfaceCollection<E extends Linked<E>>- Overrides:
removeAllin classAbstractCollection<E extends Linked<E>>
-
push
-
pop
-
iterator
-
descendingIterator
- Specified by:
descendingIteratorin interfaceDeque<E extends Linked<E>>
-