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
FieldsModifier and TypeFieldDescriptionprotected LongBigArrayThe backing array.protected longThe end position inarray.static final longThe standard initial capacity of a queue.protected longThe current (cached) length ofarray.protected longThe start position inarray. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty queue with standard initial capacity.LongBigArrayFIFOQueue(long capacity) Creates a new empty queue with given capacity. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()it.unimi.dsi.fastutil.longs.LongComparatorlongDequeues the last element from the queue.longvoidenqueue(long x) voidenqueueFirst(long x) Enqueues a new element as the first element (in dequeuing order) of the queue.longbooleanisEmpty()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, waitMethods inherited from interface it.unimi.dsi.fastutil.longs.LongPriorityQueue
dequeue, enqueue, first, lastMethods inherited from interface it.unimi.dsi.fastutil.PriorityQueue
changed
-
Field Details
-
INITIAL_CAPACITY
public static final long INITIAL_CAPACITYThe standard initial capacity of a queue.- See Also:
-
array
The backing array. -
length
protected long lengthThe current (cached) length ofarray. -
start
protected long start -
end
protected long end
-
-
Constructor Details
-
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 Details
-
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>
-