T - type of the contained elements.public class HeapPriorityQueueSet<T extends HeapPriorityQueueElement> extends HeapPriorityQueue<T> implements KeyGroupedInternalPriorityQueue<T>
HeapPriorityQueue. The heap is
supported by hash set for fast contains (de-duplication) and deletes. Object identification
happens based on Object.equals(Object).
Possible future improvements:
elementPriorityComparatorqueue, size| 构造器和说明 |
|---|
HeapPriorityQueueSet(PriorityComparator<T> elementPriorityComparator,
KeyExtractorFunction<T> keyExtractor,
int minimumCapacity,
KeyGroupRange keyGroupRange,
int totalNumberOfKeyGroups)
Creates an empty
HeapPriorityQueueSet with the requested initial capacity. |
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
add(T element)
Adds the element to the queue.
|
void |
clear()
Clears the queue.
|
Set<T> |
getSubsetForKeyGroup(int keyGroupId)
Returns the subset of elements in the priority queue that belongs to the given key-group,
within the operator's key-group range.
|
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)
In contrast to the superclass and to maintain set semantics, removal here is based on
comparing the given element via
Object.equals(Object). |
addInternal, adjustModifiedElement, getHeadElementIndex, removeInternaladdAll, isEmpty, iterator, moveElementToIdx, peek, resizeForBulkLoad, resizeQueueArray, size, toArraypublic HeapPriorityQueueSet(@Nonnull PriorityComparator<T> elementPriorityComparator, @Nonnull KeyExtractorFunction<T> keyExtractor, @Nonnegative int minimumCapacity, @Nonnull KeyGroupRange keyGroupRange, @Nonnegative int totalNumberOfKeyGroups)
HeapPriorityQueueSet with the requested initial capacity.elementPriorityComparator - comparator for the priority of contained elements.keyExtractor - function to extract a key from the contained elements.minimumCapacity - the minimum and initial capacity of this priority queue.keyGroupRange - the key-group range of the elements in this set.totalNumberOfKeyGroups - the total number of key-groups of the job.@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>poll 在类中 AbstractHeapPriorityQueue<T extends HeapPriorityQueueElement>null if this set is empty.public boolean add(@Nonnull T element)
Object.equals(Object)).add 在接口中 InternalPriorityQueue<T extends HeapPriorityQueueElement>add 在类中 AbstractHeapPriorityQueue<T extends HeapPriorityQueueElement>element - the element to add to the set.true if the operation changed the head element or if is it unclear if
the head element changed. Only returns false iff the head element was not
changed by this operation.public boolean remove(@Nonnull T toRemove)
Object.equals(Object).remove 在接口中 InternalPriorityQueue<T extends HeapPriorityQueueElement>remove 在类中 AbstractHeapPriorityQueue<T extends HeapPriorityQueueElement>toRemove - the element to remove.true if the operation changed the head element or if is it unclear if
the head element changed. Only returns false iff the head element was not
changed by this operation.public void clear()
AbstractHeapPriorityQueueclear 在类中 AbstractHeapPriorityQueue<T extends HeapPriorityQueueElement>@Nonnull public Set<T> getSubsetForKeyGroup(int keyGroupId)
KeyGroupedInternalPriorityQueuegetSubsetForKeyGroup 在接口中 KeyGroupedInternalPriorityQueue<T extends HeapPriorityQueueElement>Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.