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
Modifier and TypeClassDescriptionstatic class
Class representing two long values.static interface
Represents a function that accepts two long arguments.static interface
Predicate to checks for a key-value pair where both of them have long types. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(long item1, long item2) int
capacity()
void
clear()
boolean
exists
(long item1, long item2) void
boolean
isEmpty()
items()
items
(int numberOfItems) peek()
remove()
Removes min element from the heap.boolean
remove
(long item1, long item2) It removes all occurrence of given pair from the queue.int
Removes all of the elements of this collection that satisfy the given predicate.int
size()
-
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 returnstrue
for 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)
-