Package io.trino.util
Class LongBigArrayFIFOQueue
- java.lang.Object
-
- io.trino.util.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 Summary
Fields Modifier and Type Field Description protected LongBigArrayarrayThe backing array.protected longendThe end position inarray.static longINITIAL_CAPACITYThe standard initial capacity of a queue.protected longlengthThe current (cached) length ofarray.protected longstartThe start position inarray.
-
Constructor Summary
Constructors Constructor Description LongBigArrayFIFOQueue()Creates a new empty queue with standard initial capacity.LongBigArrayFIFOQueue(long capacity)Creates a new empty queue with given capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()it.unimi.dsi.fastutil.longs.LongComparatorcomparator()longdequeueLastLong()Dequeues the last element from the queue.longdequeueLong()voidenqueue(long x)voidenqueueFirst(long x)Enqueues a new element as the first element (in dequeuing order) of the queue.longfirstLong()booleanisEmpty()longlastLong()longlongSize()intsize()longsizeOf()voidtrim()Trims the queue to the smallest possible size.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
INITIAL_CAPACITY
public static final long INITIAL_CAPACITY
The standard initial capacity of a queue.- See Also:
- Constant Field Values
-
array
protected LongBigArray array
The backing array.
-
length
protected long length
The current (cached) length ofarray.
-
start
protected long start
-
end
protected long end
-
-
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:
comparatorin interfaceit.unimi.dsi.fastutil.longs.LongPriorityQueue- Specified by:
comparatorin interfaceit.unimi.dsi.fastutil.PriorityQueue<Long>
-
dequeueLong
public long dequeueLong()
- Specified by:
dequeueLongin interfaceit.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:
enqueuein interfaceit.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:
firstLongin interfaceit.unimi.dsi.fastutil.longs.LongPriorityQueue
-
lastLong
public long lastLong()
- Specified by:
lastLongin interfaceit.unimi.dsi.fastutil.longs.LongPriorityQueue
-
clear
public void clear()
- Specified by:
clearin interfaceit.unimi.dsi.fastutil.PriorityQueue<Long>
-
trim
public void trim()
Trims the queue to the smallest possible size.
-
size
public int size()
- Specified by:
sizein interfaceit.unimi.dsi.fastutil.PriorityQueue<Long>
-
longSize
public long longSize()
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceit.unimi.dsi.fastutil.PriorityQueue<Long>
-
-