Class GrowablePriorityLongPairQueue
java.lang.Object
org.apache.pulsar.common.util.collections.GrowablePriorityLongPairQueue
An unbounded priority queue based on a min heap where values are composed of pairs of longs.
When the capacity is reached, data will be moved to a bigger array.
It also act as a set and doesn't store duplicate values if #allowedDuplicate flag is passed false
(long,long)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass representing two long values.static interfaceRepresents a function that accepts two long arguments.static interfacePredicate to checks for a key-value pair where both of them have long types. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(long item1, long item2) intcapacity()voidclear()booleanexists(long item1, long item2) voidbooleanisEmpty()items()items(int numberOfItems) peek()remove()Removes min element from the heap.booleanremove(long item1, long item2) It removes all occurrence of given pair from the queue.intRemoves all of the elements of this collection that satisfy the given predicate.intsize()
-
Constructor Details
-
GrowablePriorityLongPairQueue
public GrowablePriorityLongPairQueue() -
GrowablePriorityLongPairQueue
public GrowablePriorityLongPairQueue(int initialCapacity)
-
-
Method Details
-
add
public void add(long item1, long item2) -
forEach
-
items
- Returns:
- a new list of all keys (makes a copy)
-
items
- Returns:
- a new list of keys with max provided numberOfItems (makes a copy)
-
removeIf
Removes all of the elements of this collection that satisfy the given predicate.- Parameters:
filter- a predicate which returnstruefor elements to be removed- Returns:
- number of removed values
-
remove
public boolean remove(long item1, long item2) It removes all occurrence of given pair from the queue.- Parameters:
item1-item2-- Returns:
-
remove
Removes min element from the heap.- Returns:
-
peek
-
isEmpty
public boolean isEmpty() -
capacity
public int capacity() -
clear
public void clear() -
size
public int size() -
exists
public boolean exists(long item1, long item2)
-