Package org.apache.flink.runtime.state
Interface InternalPriorityQueue<T>
- Type Parameters:
T- type of elements in the ordered set.
- All Known Subinterfaces:
KeyGroupedInternalPriorityQueue<T>
- All Known Implementing Classes:
AbstractHeapPriorityQueue,HeapPriorityQueue,HeapPriorityQueueSet,KeyGroupPartitionedPriorityQueue
@Internal
public interface InternalPriorityQueue<T>
Interface for collection that gives in order access to elements w.r.t their priority.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the given element to the set, if it is not already contained.voidaddAll(Collection<? extends T> toAdd) Adds all the given elements to the set.booleanisEmpty()Check if the set contains any elements.org.apache.flink.util.CloseableIterator<T>iterator()Iterator over all elements, no order guaranteed.peek()Retrieves, but does not remove, the element (w.r.t. order) of this set, or returnsnullif this set is empty.poll()Retrieves and removes the first element (w.r.t. the order) of this set, or returnsnullif this set is empty.booleanRemoves the given element from the set, if is contained in the set.intsize()Returns the number of elements in this set.
-
Method Details
-
poll
Retrieves and removes the first element (w.r.t. the order) of this set, or returnsnullif this set is empty.NOTE: Correct key (i.e. the key of the polled element) must be set on KeyContext before calling this method.
- Returns:
- the first element of this ordered set, or
nullif this set is empty.
-
peek
Retrieves, but does not remove, the element (w.r.t. order) of this set, or returnsnullif this set is empty.- Returns:
- the first element (w.r.t. order) of this ordered set, or
nullif this set is empty.
-
add
Adds the given element to the set, if it is not already contained.- Parameters:
toAdd- the element to add to the set.- Returns:
trueif the operation changed the head element or if it is unclear if the head element changed. Only returnsfalseif the head element was not changed by this operation.
-
remove
Removes the given element from the set, if is contained in the set.NOTE: Correct key (i.e. the key of the polled element) must be set on KeyContext before calling this method.
- Parameters:
toRemove- the element to remove.- Returns:
trueif the operation changed the head element or if it is unclear if the head element changed. Only returnsfalseif the head element was not changed by this operation.
-
isEmpty
boolean isEmpty()Check if the set contains any elements.- Returns:
- true if the set is empty, i.e. no element is contained.
-
size
@Nonnegative int size()Returns the number of elements in this set.- Returns:
- the number of elements in this set.
-
addAll
Adds all the given elements to the set. -
iterator
Iterator over all elements, no order guaranteed. Iterator must be closed after usage.
-