Class GrowablePriorityLongPairQueue
- java.lang.Object
-
- org.apache.pulsar.common.util.collections.GrowablePriorityLongPairQueue
-
public class GrowablePriorityLongPairQueue extends java.lang.ObjectAn 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
#allowedDuplicateflag is passed false(long,long)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGrowablePriorityLongPairQueue.LongPairClass representing two long values.static interfaceGrowablePriorityLongPairQueue.LongPairConsumerRepresents a function that accepts two long arguments.static interfaceGrowablePriorityLongPairQueue.LongPairPredicatePredicate to checks for a key-value pair where both of them have long types.
-
Constructor Summary
Constructors Constructor Description GrowablePriorityLongPairQueue()GrowablePriorityLongPairQueue(int initialCapacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(long item1, long item2)intcapacity()voidclear()booleanexists(long item1, long item2)voidforEach(GrowablePriorityLongPairQueue.LongPairConsumer processor)booleanisEmpty()java.util.Set<GrowablePriorityLongPairQueue.LongPair>items()java.util.Set<GrowablePriorityLongPairQueue.LongPair>items(int numberOfItems)GrowablePriorityLongPairQueue.LongPairpeek()GrowablePriorityLongPairQueue.LongPairremove()Removes min element from the heap.booleanremove(long item1, long item2)It removes all occurrence of given pair from the queue.intremoveIf(GrowablePriorityLongPairQueue.LongPairPredicate filter)Removes all of the elements of this collection that satisfy the given predicate.intsize()
-
-
-
Method Detail
-
add
public void add(long item1, long item2)
-
forEach
public void forEach(GrowablePriorityLongPairQueue.LongPairConsumer processor)
-
items
public java.util.Set<GrowablePriorityLongPairQueue.LongPair> items()
- Returns:
- a new list of all keys (makes a copy)
-
items
public java.util.Set<GrowablePriorityLongPairQueue.LongPair> items(int numberOfItems)
- Returns:
- a new list of keys with max provided numberOfItems (makes a copy)
-
removeIf
public int removeIf(GrowablePriorityLongPairQueue.LongPairPredicate filter)
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
public GrowablePriorityLongPairQueue.LongPair remove()
Removes min element from the heap.- Returns:
-
peek
public GrowablePriorityLongPairQueue.LongPair 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)
-
-