T - type of the elements contained in the priority queue.public abstract class AbstractHeapPriorityQueue<T extends HeapPriorityQueueElement> extends Object implements InternalPriorityQueue<T>
HeapPriorityQueueElement.| 限定符和类型 | 字段和说明 |
|---|---|
protected T[] |
queue
The array that represents the heap-organized priority queue.
|
protected int |
size
The current size of the priority queue.
|
| 构造器和说明 |
|---|
AbstractHeapPriorityQueue(int minimumCapacity) |
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
add(T toAdd)
Adds the given element to the set, if it is not already contained.
|
void |
addAll(Collection<? extends T> toAdd)
Adds all the given elements to the set.
|
protected abstract void |
addInternal(T toAdd)
Implements how to add an element to the queue.
|
void |
clear()
Clears the queue.
|
protected abstract int |
getHeadElementIndex()
Returns the start index of the queue elements in the array.
|
boolean |
isEmpty()
Check if the set contains any elements.
|
org.apache.flink.util.CloseableIterator<T> |
iterator()
Returns an iterator over the elements in this queue.
|
protected void |
moveElementToIdx(T element,
int idx) |
T |
peek()
Retrieves, but does not remove, the element (w.r.t. order) of this set, or returns
null if this set is empty. |
T |
poll()
Retrieves and removes the first element (w.r.t. the order) of this set, or returns
null if this set is empty. |
boolean |
remove(T toRemove)
Removes the given element from the set, if is contained in the set.
|
protected abstract T |
removeInternal(int elementIndex)
Implements how to remove the element at the given index from the queue.
|
protected void |
resizeForBulkLoad(int totalSize) |
protected void |
resizeQueueArray(int desiredSize,
int minRequiredSize) |
int |
size()
Returns the number of elements in this set.
|
<O> O[] |
toArray(O[] out) |
@Nonnull protected T extends HeapPriorityQueueElement[] queue
@Nonnegative protected int size
public AbstractHeapPriorityQueue(@Nonnegative int minimumCapacity)
@Nullable public T poll()
InternalPriorityQueuenull if this set is empty.
NOTE: Correct key (i.e. the key of the polled element) must be set on KeyContext before calling this method.
poll 在接口中 InternalPriorityQueue<T extends HeapPriorityQueueElement>null if this set is empty.@Nullable public T peek()
InternalPriorityQueuenull if this set is empty.peek 在接口中 InternalPriorityQueue<T extends HeapPriorityQueueElement>null if this set is
empty.public boolean add(@Nonnull T toAdd)
InternalPriorityQueueadd 在接口中 InternalPriorityQueue<T extends HeapPriorityQueueElement>toAdd - the element to add to the set.true if the operation changed the head element or if it is unclear if
the head element changed. Only returns false if the head element was not
changed by this operation.public boolean remove(@Nonnull T toRemove)
InternalPriorityQueueNOTE: Correct key (i.e. the key of the polled element) must be set on KeyContext before calling this method.
remove 在接口中 InternalPriorityQueue<T extends HeapPriorityQueueElement>toRemove - the element to remove.true if the operation changed the head element or if it is unclear if
the head element changed. Only returns false if the head element was not
changed by this operation.public boolean isEmpty()
InternalPriorityQueueisEmpty 在接口中 InternalPriorityQueue<T extends HeapPriorityQueueElement>public int size()
InternalPriorityQueuesize 在接口中 InternalPriorityQueue<T extends HeapPriorityQueueElement>public void addAll(@Nullable Collection<? extends T> toAdd)
InternalPriorityQueueaddAll 在接口中 InternalPriorityQueue<T extends HeapPriorityQueueElement>@Nonnull public <O> O[] toArray(O[] out)
@Nonnull public org.apache.flink.util.CloseableIterator<T> iterator()
iterator 在接口中 InternalPriorityQueue<T extends HeapPriorityQueueElement>public void clear()
protected void resizeForBulkLoad(int totalSize)
protected void resizeQueueArray(int desiredSize,
int minRequiredSize)
protected void moveElementToIdx(T element, int idx)
protected abstract T removeInternal(@Nonnegative int elementIndex)
elementIndex - the index to remove.protected abstract void addInternal(@Nonnull T toAdd)
toAdd - the element to add.protected abstract int getHeadElementIndex()
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.