Class TripleLongPriorityQueue

  • All Implemented Interfaces:
    java.lang.AutoCloseable

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

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      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 bytesCapacity()
      The amount of memory used to back the priority queue.
      void clear()
      Clear all items.
      void close()
      Close the priority queue and free the memory associated.
      boolean isEmpty()
      Returns whether the priority queue is empty.
      long peekN1()
      Read the 1st long item in the top tuple in the priority queue.
      long peekN2()
      Read the 2nd long item in the top tuple in the priority queue.
      long peekN3()
      Read the 3rd long item in the top tuple in the priority queue.
      void pop()
      Removes the first item from the queue.
      long size()
      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 Detail

      • 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 Detail

      • close

        public void close()
        Close the priority queue and free the memory associated.
        Specified by:
        close in interface java.lang.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.