Class TripleLongPriorityQueue
java.lang.Object
org.apache.pulsar.common.util.collections.TripleLongPriorityQueue
- All Implemented Interfaces:
AutoCloseable
Provides a priority-queue implementation specialized on items composed by 3 longs.
This class is not thread safe and the items are stored in direct memory.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new priority queue with default initial capacity.TripleLongPriorityQueue(int initialCapacity) Create a new priority queue with a given initial capacity.TripleLongPriorityQueue(long initialCapacity, float shrinkFactor) -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(long n1, long n2, long n3) Add a tuple of 3 long items to the priority queue.longThe amount of memory used to back the priority queue.voidclear()Clear all items.voidclose()Close the priority queue and free the memory associated.booleanisEmpty()Returns whether the priority queue is empty.longpeekN1()Read the 1st long item in the top tuple in the priority queue.longpeekN2()Read the 2nd long item in the top tuple in the priority queue.longpeekN3()Read the 3rd long item in the top tuple in the priority queue.voidpop()Removes the first item from the queue.longsize()Returns the number of tuples in the priority queue.
-
Constructor Details
-
TripleLongPriorityQueue
public TripleLongPriorityQueue()Create a new priority queue with default initial capacity. -
TripleLongPriorityQueue
public TripleLongPriorityQueue(long initialCapacity, float shrinkFactor) -
TripleLongPriorityQueue
public TripleLongPriorityQueue(int initialCapacity) Create a new priority queue with a given initial capacity.- Parameters:
initialCapacity-
-
-
Method Details
-
close
public void close()Close the priority queue and free the memory associated.- Specified by:
closein interfaceAutoCloseable
-
add
public void add(long n1, long n2, long n3) Add a tuple of 3 long items to the priority queue.- Parameters:
n1-n2-n3-
-
peekN1
public long peekN1()Read the 1st long item in the top tuple in the priority queue.The tuple will not be extracted
-
peekN2
public long peekN2()Read the 2nd long item in the top tuple in the priority queue.The tuple will not be extracted
-
peekN3
public long peekN3()Read the 3rd long item in the top tuple in the priority queue.The tuple will not be extracted
-
pop
public void pop()Removes the first item from the queue. -
isEmpty
public boolean isEmpty()Returns whether the priority queue is empty. -
size
public long size()Returns the number of tuples in the priority queue. -
bytesCapacity
public long bytesCapacity()The amount of memory used to back the priority queue. -
clear
public void clear()Clear all items.
-