T - type of the elements contained in the priority queue.public abstract class AbstractHeapPriorityQueue<T extends HeapPriorityQueueElement> extends Object implements InternalPriorityQueue<T>
HeapPriorityQueueElement.| Modifier and Type | Field and Description |
|---|---|
protected T[] |
queue
The array that represents the heap-organized priority queue.
|
protected int |
size
The current size of the priority queue.
|
| Constructor and Description |
|---|
AbstractHeapPriorityQueue(int minimumCapacity) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
T |
poll()
Retrieves and removes the first element (w.r.t.
|
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.poll in interface InternalPriorityQueue<T extends HeapPriorityQueueElement>null if this set is empty.@Nullable public T peek()
InternalPriorityQueuenull if this set is empty.peek in interface InternalPriorityQueue<T extends HeapPriorityQueueElement>null if this set is
empty.public boolean add(@Nonnull T toAdd)
InternalPriorityQueueadd in interface 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)
InternalPriorityQueueremove in interface 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 in interface InternalPriorityQueue<T extends HeapPriorityQueueElement>public int size()
InternalPriorityQueuesize in interface InternalPriorityQueue<T extends HeapPriorityQueueElement>public void addAll(@Nullable Collection<? extends T> toAdd)
InternalPriorityQueueaddAll in interface InternalPriorityQueue<T extends HeapPriorityQueueElement>@Nonnull public <O> O[] toArray(O[] out)
@Nonnull public org.apache.flink.util.CloseableIterator<T> iterator()
iterator in interface 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–2022 The Apache Software Foundation. All rights reserved.