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| Constructor and Description |
|---|
HeapPriorityQueueSet(PriorityComparator<T> elementPriorityComparator,
KeyExtractorFunction<T> keyExtractor,
int minimumCapacity,
KeyGroupRange keyGroupRange,
int totalNumberOfKeyGroups)
Creates an empty
HeapPriorityQueueSet with the requested initial capacity. |
| Modifier and Type | Method and Description |
|---|---|
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.
|
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 in interface InternalPriorityQueue<T extends HeapPriorityQueueElement>poll in class AbstractHeapPriorityQueue<T extends HeapPriorityQueueElement>null if this set is empty.public boolean add(@Nonnull T element)
Object.equals(Object)).add in interface InternalPriorityQueue<T extends HeapPriorityQueueElement>add in class 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 in interface InternalPriorityQueue<T extends HeapPriorityQueueElement>remove in class 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 in class AbstractHeapPriorityQueue<T extends HeapPriorityQueueElement>@Nonnull public Set<T> getSubsetForKeyGroup(int keyGroupId)
KeyGroupedInternalPriorityQueuegetSubsetForKeyGroup in interface KeyGroupedInternalPriorityQueue<T extends HeapPriorityQueueElement>Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.