Class TripleLongPriorityQueue

java.lang.Object
org.apache.pulsar.common.util.collections.TripleLongPriorityQueue
All Implemented Interfaces:
AutoCloseable

public class TripleLongPriorityQueue extends Object implements 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

    Constructors
    Constructor
    Description
    Create 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 Type
    Method
    Description
    void
    add(long n1, long n2, long n3)
    Add a tuple of 3 long items to the priority queue.
    long
    The amount of memory used to back the priority queue.
    void
    Clear all items.
    void
    Close the priority queue and free the memory associated.
    boolean
    Returns whether the priority queue is empty.
    long
    Read the 1st long item in the top tuple in the priority queue.
    long
    Read the 2nd long item in the top tuple in the priority queue.
    long
    Read the 3rd long item in the top tuple in the priority queue.
    void
    pop()
    Removes the first item from the queue.
    long
    Returns the number of tuples in the priority queue.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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:
      close in interface AutoCloseable
    • 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.