public class DoubleArrayPriorityQueue extends java.lang.Object implements DoublePriorityQueue, 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 double[] |
array
The backing array.
|
protected it.unimi.dsi.fastutil.doubles.DoubleComparator |
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 |
|---|
DoubleArrayPriorityQueue()
Creates a new empty queue using the natural order.
|
DoubleArrayPriorityQueue(double[] a)
Wraps a given array in a queue using the natural order.
|
DoubleArrayPriorityQueue(double[] a,
it.unimi.dsi.fastutil.doubles.DoubleComparator c)
Wraps a given array in a queue using a given comparator.
|
DoubleArrayPriorityQueue(double[] a,
int size)
Wraps a given array in a queue using the natural order.
|
DoubleArrayPriorityQueue(double[] a,
int size,
it.unimi.dsi.fastutil.doubles.DoubleComparator c)
Wraps a given array in a queue using a given comparator.
|
DoubleArrayPriorityQueue(it.unimi.dsi.fastutil.doubles.DoubleComparator c)
Creates a new empty queue with a given comparator.
|
DoubleArrayPriorityQueue(int capacity)
Creates a new empty queue with a given capacity and using the natural order.
|
DoubleArrayPriorityQueue(int capacity,
it.unimi.dsi.fastutil.doubles.DoubleComparator 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.doubles.DoubleComparator |
comparator()
Returns the comparator associated with this priority queue, or null if it uses its elements' natural ordering.
|
double |
dequeueDouble()
Dequeues the first element from the queue.
|
void |
enqueue(double x)
Enqueues a new element.
|
double |
firstDouble()
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, waitdequeue, enqueue, first, last, lastDoubleprotected transient double[] array
protected int size
protected it.unimi.dsi.fastutil.doubles.DoubleComparator c
protected transient int firstIndex
firstIndexValid is true.protected transient boolean firstIndexValid
firstIndex contains a valid value.public DoubleArrayPriorityQueue(int capacity,
it.unimi.dsi.fastutil.doubles.DoubleComparator c)
capacity - the initial capacity of this queue.c - the comparator used in this queue, or null for the natural order.public DoubleArrayPriorityQueue(int capacity)
capacity - the initial capacity of this queue.public DoubleArrayPriorityQueue(it.unimi.dsi.fastutil.doubles.DoubleComparator c)
c - the comparator used in this queue, or null for the natural order.public DoubleArrayPriorityQueue()
public DoubleArrayPriorityQueue(double[] a,
int size,
it.unimi.dsi.fastutil.doubles.DoubleComparator 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 DoubleArrayPriorityQueue(double[] a,
it.unimi.dsi.fastutil.doubles.DoubleComparator 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 DoubleArrayPriorityQueue(double[] 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 DoubleArrayPriorityQueue(double[] a)
The queue returned by this method will be backed by the given array.
a - an array.public void enqueue(double x)
DoublePriorityQueueenqueue in interface DoublePriorityQueuex - the element to enqueue.PriorityQueue.enqueue(Object)public double dequeueDouble()
DoublePriorityQueuedequeueDouble in interface DoublePriorityQueueDoublePriorityQueue.dequeue()public double firstDouble()
DoublePriorityQueuefirstDouble in interface DoublePriorityQueueDoublePriorityQueue.first()public void changed()
changed in interface it.unimi.dsi.fastutil.PriorityQueue<java.lang.Double>public int size()
size in interface it.unimi.dsi.fastutil.PriorityQueue<java.lang.Double>public void clear()
clear in interface it.unimi.dsi.fastutil.PriorityQueue<java.lang.Double>public void trim()
size() elements.public it.unimi.dsi.fastutil.doubles.DoubleComparator comparator()
DoublePriorityQueuecomparator in interface DoublePriorityQueuecomparator in interface it.unimi.dsi.fastutil.PriorityQueue<java.lang.Double>PriorityQueue.comparator()