T - the element type.@Internal public final class PrioritizedDeque<T> extends Object implements Iterable<T>
Note that all element tests are performed by identity.
| 构造器和说明 |
|---|
PrioritizedDeque() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
add(T element)
Adds a non-priority element to this deque, which will be polled last.
|
void |
add(T element,
boolean priority,
boolean prioritize)
Convenience method for adding an element with optional priority and prior removal.
|
void |
addPriorityElement(T element)
Adds a priority element to this deque, such that it will be polled after all existing
priority elements but before any non-priority element.
|
Collection<T> |
asUnmodifiableCollection()
Returns an unmodifiable collection view.
|
void |
clear()
Removes all priority and non-priority elements.
|
boolean |
contains(T element)
Returns whether the given element is contained in this list.
|
boolean |
containsPriorityElement(T element)
Returns whether the given element is a known priority element.
|
boolean |
equals(Object o) |
T |
getAndRemove(java.util.function.Predicate<T> preCondition)
Find first element matching the
Predicate, remove it from the PrioritizedDeque and return it. |
int |
getNumPriorityElements()
Returns the current number of priority elements ([0;
size()]). |
int |
getNumUnprioritizedElements()
Returns the number of non-priority elements.
|
int |
hashCode() |
boolean |
isEmpty()
Returns true if there are no elements.
|
Iterator<T> |
iterator() |
T |
peek()
Returns the first priority element or non-priority element if the former does not exist.
|
T |
peekLast()
Returns the last non-priority element or priority element if the former does not exist.
|
T |
poll()
Polls the first priority element or non-priority element if the former does not exist.
|
void |
prioritize(T element)
Prioritizes an already existing element.
|
int |
size()
Returns the number of priority and non-priority elements.
|
java.util.stream.Stream<T> |
stream() |
String |
toString() |
forEach, spliteratorpublic void addPriorityElement(T element)
element - the element to addpublic void add(T element)
element - the element to addpublic void add(T element, boolean priority, boolean prioritize)
element - the element to addpriority - flag indicating if it's a priority or non-priority elementprioritize - flag that hints that the element is already in this deque, potentially as
non-priority element.public void prioritize(T element)
element - the element to prioritize.public Collection<T> asUnmodifiableCollection()
public T getAndRemove(java.util.function.Predicate<T> preCondition)
Predicate, remove it from the PrioritizedDeque and return it.@Nullable public T poll()
@Nullable public T peek()
public int getNumPriorityElements()
size()]).public boolean containsPriorityElement(T element)
public int size()
public int getNumUnprioritizedElements()
public void clear()
public boolean isEmpty()
public boolean contains(T element)
@Nullable public T peekLast()
public java.util.stream.Stream<T> stream()
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.