Package io.trino.util

Class LongBigArrayFIFOQueue

  • All Implemented Interfaces:
    it.unimi.dsi.fastutil.longs.LongPriorityQueue, it.unimi.dsi.fastutil.PriorityQueue<Long>

    public class LongBigArrayFIFOQueue
    extends Object
    implements it.unimi.dsi.fastutil.longs.LongPriorityQueue
    A type-specific array-based FIFO queue, supporting also deque operations.

    Instances of this class represent a FIFO queue using a backing array in a circular way. The array is enlarged and shrunk as needed. You can use the trim() method to reduce its memory usage, if necessary.

    This class provides additional methods that implement a deque (double-ended queue).

    • Field Detail

      • INITIAL_CAPACITY

        public static final long INITIAL_CAPACITY
        The standard initial capacity of a queue.
        See Also:
        Constant Field Values
      • length

        protected long length
        The current (cached) length of array.
      • start

        protected long start
        The start position in array. It is always strictly smaller than length.
      • end

        protected long end
        The end position in array. It is always strictly smaller than length. Might be actually smaller than start because array is used cyclically.
    • Constructor Detail

      • LongBigArrayFIFOQueue

        public LongBigArrayFIFOQueue​(long capacity)
        Creates a new empty queue with given capacity.
        Parameters:
        capacity - the initial capacity of this queue.
      • LongBigArrayFIFOQueue

        public LongBigArrayFIFOQueue()
        Creates a new empty queue with standard initial capacity.
    • Method Detail

      • sizeOf

        public long sizeOf()
      • comparator

        public it.unimi.dsi.fastutil.longs.LongComparator comparator()

        This implementation returns null (FIFO queues have no comparator).

        Specified by:
        comparator in interface it.unimi.dsi.fastutil.longs.LongPriorityQueue
        Specified by:
        comparator in interface it.unimi.dsi.fastutil.PriorityQueue<Long>
      • dequeueLong

        public long dequeueLong()
        Specified by:
        dequeueLong in interface it.unimi.dsi.fastutil.longs.LongPriorityQueue
      • dequeueLastLong

        public long dequeueLastLong()
        Dequeues the last element from the queue.
        Returns:
        the dequeued element.
        Throws:
        NoSuchElementException - if the queue is empty.
      • enqueue

        public void enqueue​(long x)
        Specified by:
        enqueue in interface it.unimi.dsi.fastutil.longs.LongPriorityQueue
      • enqueueFirst

        public void enqueueFirst​(long x)
        Enqueues a new element as the first element (in dequeuing order) of the queue.
        Parameters:
        x - the element to enqueue.
      • firstLong

        public long firstLong()
        Specified by:
        firstLong in interface it.unimi.dsi.fastutil.longs.LongPriorityQueue
      • lastLong

        public long lastLong()
        Specified by:
        lastLong in interface it.unimi.dsi.fastutil.longs.LongPriorityQueue
      • clear

        public void clear()
        Specified by:
        clear in interface it.unimi.dsi.fastutil.PriorityQueue<Long>
      • trim

        public void trim()
        Trims the queue to the smallest possible size.
      • size

        public int size()
        Specified by:
        size in interface it.unimi.dsi.fastutil.PriorityQueue<Long>
      • longSize

        public long longSize()
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface it.unimi.dsi.fastutil.PriorityQueue<Long>