public class ByteArrayPriorityQueue extends java.lang.Object implements BytePriorityQueue, java.io.Serializable
Instances of this class represent a priority queue using a backing
array—all operations are performed directly on the array. The array is
enlarged as needed, but it is never shrunk. Use the trim() method
to reduce its size, if necessary.
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
array
The backing array.
|
protected it.unimi.dsi.fastutil.bytes.ByteComparator |
c
The type-specific comparator used in this queue.
|
protected int |
firstIndex
The first index, cached, if
firstIndexValid is true. |
protected boolean |
firstIndexValid
Whether
firstIndex contains a valid value. |
protected int |
size
The number of elements in this queue.
|
| Constructor and Description |
|---|
ByteArrayPriorityQueue()
Creates a new empty queue using the natural order.
|
ByteArrayPriorityQueue(byte[] a)
Wraps a given array in a queue using the natural order.
|
ByteArrayPriorityQueue(byte[] a,
it.unimi.dsi.fastutil.bytes.ByteComparator c)
Wraps a given array in a queue using a given comparator.
|
ByteArrayPriorityQueue(byte[] a,
int size)
Wraps a given array in a queue using the natural order.
|
ByteArrayPriorityQueue(byte[] a,
int size,
it.unimi.dsi.fastutil.bytes.ByteComparator c)
Wraps a given array in a queue using a given comparator.
|
ByteArrayPriorityQueue(it.unimi.dsi.fastutil.bytes.ByteComparator c)
Creates a new empty queue with a given comparator.
|
ByteArrayPriorityQueue(int capacity)
Creates a new empty queue with a given capacity and using the natural order.
|
ByteArrayPriorityQueue(int capacity,
it.unimi.dsi.fastutil.bytes.ByteComparator c)
Creates a new empty queue with a given capacity and comparator.
|
| Modifier and Type | Method and Description |
|---|---|
void |
changed() |
void |
clear() |
it.unimi.dsi.fastutil.bytes.ByteComparator |
comparator()
Returns the comparator associated with this priority queue, or null if it uses its elements' natural ordering.
|
byte |
dequeueByte()
Dequeues the first element from the queue.
|
void |
enqueue(byte x)
Enqueues a new element.
|
byte |
firstByte()
Returns the first element of the queue.
|
int |
size() |
void |
trim()
Trims the underlying array so that it has exactly
size() elements. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitprotected transient byte[] array
protected int size
protected it.unimi.dsi.fastutil.bytes.ByteComparator c
protected transient int firstIndex
firstIndexValid is true.protected transient boolean firstIndexValid
firstIndex contains a valid value.public ByteArrayPriorityQueue(int capacity,
it.unimi.dsi.fastutil.bytes.ByteComparator c)
capacity - the initial capacity of this queue.c - the comparator used in this queue, or null for the natural order.public ByteArrayPriorityQueue(int capacity)
capacity - the initial capacity of this queue.public ByteArrayPriorityQueue(it.unimi.dsi.fastutil.bytes.ByteComparator c)
c - the comparator used in this queue, or null for the natural order.public ByteArrayPriorityQueue()
public ByteArrayPriorityQueue(byte[] a,
int size,
it.unimi.dsi.fastutil.bytes.ByteComparator c)
The queue returned by this method will be backed by the given array.
a - an array.size - the number of elements to be included in the queue.c - the comparator used in this queue, or null for the natural order.public ByteArrayPriorityQueue(byte[] a,
it.unimi.dsi.fastutil.bytes.ByteComparator c)
The queue returned by this method will be backed by the given array.
a - an array.c - the comparator used in this queue, or null for the natural order.public ByteArrayPriorityQueue(byte[] a,
int size)
The queue returned by this method will be backed by the given array.
a - an array.size - the number of elements to be included in the queue.public ByteArrayPriorityQueue(byte[] a)
The queue returned by this method will be backed by the given array.
a - an array.public void enqueue(byte x)
BytePriorityQueueenqueue in interface BytePriorityQueuex - the element to enqueue.PriorityQueue.enqueue(Object)public byte dequeueByte()
BytePriorityQueuedequeueByte in interface BytePriorityQueueBytePriorityQueue.dequeue()public byte firstByte()
BytePriorityQueuefirstByte in interface BytePriorityQueueBytePriorityQueue.first()public void changed()
changed in interface it.unimi.dsi.fastutil.PriorityQueue<java.lang.Byte>public int size()
size in interface it.unimi.dsi.fastutil.PriorityQueue<java.lang.Byte>public void clear()
clear in interface it.unimi.dsi.fastutil.PriorityQueue<java.lang.Byte>public void trim()
size() elements.public it.unimi.dsi.fastutil.bytes.ByteComparator comparator()
BytePriorityQueuecomparator in interface BytePriorityQueuecomparator in interface it.unimi.dsi.fastutil.PriorityQueue<java.lang.Byte>PriorityQueue.comparator()