Class PartialOrderPriorityQueue<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<T>
org.apache.flink.runtime.operators.sort.PartialOrderPriorityQueue<T>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,Queue<T>
This class implements a priority-queue, which maintains a partial ordering of its elements such
that the least element can always be found in constant time. Put()'s and pop()'s require
log(size) time.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidShould be called when the Object at top changes values.final voidclear()Removes all entries from the PriorityQueue.iterator()booleanAdds element to the PriorityQueue in log(size) time if either the PriorityQueue is not full, or not lessThan(element, top()).final Tpeek()Returns the least element of the PriorityQueue in constant time, but does not remove it from the priority queue.final Tpoll()Removes and returns the least element of the PriorityQueue in log(size) time.final voidAdds a buffer to a PriorityQueue in log(size) time.intReturns the remaining capacity of the backing array.final intsize()Returns the number of elements currently stored in the PriorityQueue.Methods inherited from class java.util.AbstractQueue
add, addAll, element, removeMethods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, 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
addAll, contains, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
Constructor Details
-
PartialOrderPriorityQueue
-
-
Method Details
-
remainingCapacity
public int remainingCapacity()Returns the remaining capacity of the backing array.- Returns:
- The remaining capacity of the backing array.
-
put
Adds a buffer to a PriorityQueue in log(size) time. If one tries to add more objects than maxSize from initialize a RuntimeException (ArrayIndexOutOfBound) is thrown. -
offer
Adds element to the PriorityQueue in log(size) time if either the PriorityQueue is not full, or not lessThan(element, top()). -
peek
Returns the least element of the PriorityQueue in constant time, but does not remove it from the priority queue. -
poll
Removes and returns the least element of the PriorityQueue in log(size) time. -
adjustTop
public final void adjustTop()Should be called when the Object at top changes values. Still log(n) worst case, but it's at least twice as fast to{ pq.top().change(); pq.adjustTop(); }instead of{ o = pq.pop(); o.change(); pq.push(o); } -
size
public final int size()Returns the number of elements currently stored in the PriorityQueue.- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein classAbstractCollection<T>- Returns:
- The number of elements in the queue.
-
clear
public final void clear()Removes all entries from the PriorityQueue.- Specified by:
clearin interfaceCollection<T>- Overrides:
clearin classAbstractQueue<T>
-
iterator
- Specified by:
iteratorin interfaceCollection<T>- Specified by:
iteratorin interfaceIterable<T>- Specified by:
iteratorin classAbstractCollection<T>
-