|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unimi.dsi.fastutil.AbstractIndirectPriorityQueue<Double>
it.unimi.dsi.fastutil.doubles.DoubleHeapSemiIndirectPriorityQueue
it.unimi.dsi.fastutil.doubles.DoubleHeapSesquiIndirectDoublePriorityQueue
public class DoubleHeapSesquiIndirectDoublePriorityQueue
A type-specific heap-based sesqui-indirect double priority queue.
Instances of this class are based on a semi-indirect and an indirect
heap-based queues. The queues are enlarged as needed, but they are never
shrunk. Use the trim()
method to reduce their size, if necessary.
Either comparator may be null
, indicating that natural comparison should take place. Of course,
it makes little sense having them equal.
Constructor Summary | |
---|---|
DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray)
Creates a new empty queue with capacity equal to the length of the reference array and natural order as primary comparator. |
|
DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray,
DoubleComparator c)
Creates a new empty queue with capacity equal to the length of the reference array. |
|
DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray,
DoubleComparator c,
DoubleComparator d)
Creates a new empty queue with capacity equal to the length of the reference array. |
|
DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray,
int capacity)
Creates a new empty queue with a given capacity and natural order as primary comparator. |
|
DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray,
int[] a)
Wraps a given array in a queue using the natural order. |
|
DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray,
int[] a,
DoubleComparator c)
Wraps a given array in a queue using a given comparator. |
|
DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray,
int[] a,
DoubleComparator c,
DoubleComparator d)
Wraps a given array in a queue using the given comparators. |
|
DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray,
int[] a,
int size)
Wraps a given array in a queue using the natural order. |
|
DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray,
int[] a,
int size,
DoubleComparator c)
Wraps a given array in a queue using a given comparator. |
|
DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray,
int[] a,
int size,
DoubleComparator c,
DoubleComparator d)
Wraps a given array in a queue using the given comparators. |
|
DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray,
int capacity,
DoubleComparator c)
Creates a new empty queue with a given capacity. |
|
DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray,
int capacity,
DoubleComparator c,
DoubleComparator d)
Creates a new empty queue with a given capacity. |
Method Summary | |
---|---|
void |
allChanged()
Rebuilds this heap in a bottom-up fashion. |
void |
changed()
Notifies the queue that the first element has changed (optional operation). |
void |
clear()
Removes all elements from this queue. |
int |
dequeue()
Dequeues the first element from the queue. |
void |
enqueue(int x)
Enqueues a new element. |
DoubleComparator |
secondaryComparator()
Returns the secondary comparator of this queue. |
int |
secondaryFirst()
Returns the first element of this queue with respect to the secondary comparator. |
int |
secondaryFront(int[] a)
Retrieves the secondary front of the queue in a given array (optional operation). |
int |
secondaryLast()
Returns the last element of this queue with respect to the secondary comparator (optional operation). |
void |
trim()
Trims the underlying queues so they have exactly DoubleHeapSemiIndirectPriorityQueue.size() elements. |
Methods inherited from class it.unimi.dsi.fastutil.doubles.DoubleHeapSemiIndirectPriorityQueue |
---|
comparator, first, front, size, toString |
Methods inherited from class it.unimi.dsi.fastutil.AbstractIndirectPriorityQueue |
---|
changed, isEmpty, last, remove |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface it.unimi.dsi.fastutil.doubles.DoubleIndirectPriorityQueue |
---|
comparator |
Methods inherited from interface it.unimi.dsi.fastutil.IndirectPriorityQueue |
---|
changed, first, front, isEmpty, last, remove, size |
Constructor Detail |
---|
public DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray, int capacity, DoubleComparator c, DoubleComparator d)
refArray
- the reference array.capacity
- the initial capacity of this queue.c
- the primary comparator used in this queue, or null
for the natural order.d
- the secondary comparator used in this queue, or null
for the natural order.public DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray, int capacity, DoubleComparator c)
This constructor uses as secondary comparator the opposite order of c
.
refArray
- the reference array.capacity
- the initial capacity of this queue.c
- the primary comparator used in this queue, or null
for the natural order.public DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray, int capacity)
This constructor uses as secondary comparator the opposite of the natural order.
refArray
- the reference array.capacity
- the initial capacity of this queue.public DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray, DoubleComparator c, DoubleComparator d)
refArray
- the reference array.c
- the primary comparator used in this queue, or null
for the natural order.d
- the secondary comparator used in this queue, or null
for the natural order.public DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray, DoubleComparator c)
This constructor uses as secondary comparator the opposite order of c
.
refArray
- the reference array.c
- the primary comparator used in this queue, or null
for the natural order.public DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray)
This constructor uses as secondary comparator the opposite of the natural order.
refArray
- the reference array.public DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray, int[] a, int size, DoubleComparator c, DoubleComparator d)
The queue returned by this method will be backed by the given array.
The first size
element of the array will be rearranged so to form a heap, and
moreover the array will be cloned and wrapped in a secondary queue (this is
more efficient than enqueing the elements of a
one by one).
refArray
- the reference array.a
- an array of indices into refArray
.size
- the number of elements to be included in the queue.c
- the primary comparator used in this queue, or null
for the natural order.d
- the secondary comparator used in this queue, or null
for the natural order.public DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray, int[] a, DoubleComparator c, DoubleComparator d)
The queue returned by this method will be backed by the given array.
The first elements of the array will be rearranged so to form a heap, and
moreover the array will be cloned and wrapped in a secondary queue (this is
more efficient than enqueing the elements of a
one by one).
refArray
- the reference array.a
- an array of indices into refArray
.c
- the primary comparator used in this queue, or null
for the natural order.d
- the secondary comparator used in this queue, or null
for the natural order.public DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray, int[] a, int size, DoubleComparator c)
The queue returned by this method will be backed by the given array.
The first size
element of the array will be rearranged so to form a heap, and
moreover the array will be cloned and wrapped in a secondary queue (this is
more efficient than enqueing the elements of a
one by one).
This constructor uses as secondary comparator the opposite order of c
.
refArray
- the reference array.a
- an array of indices into refArray
.size
- the number of elements to be included in the queue.c
- the primary comparator used in this queue, or null
for the natural order.public DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray, int[] a, DoubleComparator c)
The queue returned by this method will be backed by the given array.
The elements of the array will be rearranged so to form a heap, and
moreover the array will be cloned and wrapped in a secondary queue (this is
more efficient than enqueing the elements of a
one by one).
This constructor uses as secondary comparator the opposite order of c
.
refArray
- the reference array.a
- an array of indices into refArray
.c
- the primary comparator used in this queue, or null
for the natural order.public DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray, int[] a, int size)
The queue returned by this method will be backed by the given array.
The first size
element of the array will be rearranged so to form a heap, and
moreover the array will be cloned and wrapped in a secondary queue (this is
more efficient than enqueing the elements of a
one by one).
This constructor uses as secondary comparator the opposite of the natural order.
refArray
- the reference array.a
- an array of indices into refArray
.size
- the number of elements to be included in the queue.public DoubleHeapSesquiIndirectDoublePriorityQueue(double[] refArray, int[] a)
The queue returned by this method will be backed by the given array.
The elements of the array will be rearranged so to form a heap, and
moreover the array will be cloned and wrapped in a secondary queue (this is
more efficient than enqueing the elements of a
one by one).
This constructor uses as secondary comparator the opposite of the natural order.
refArray
- the reference array.a
- an array of indices into refArray
.Method Detail |
---|
public void enqueue(int x)
IndirectPriorityQueue
enqueue
in interface IndirectPriorityQueue<Double>
enqueue
in class DoubleHeapSemiIndirectPriorityQueue
x
- the element to enqueue..public int dequeue()
IndirectPriorityQueue
dequeue
in interface IndirectPriorityQueue<Double>
dequeue
in class DoubleHeapSemiIndirectPriorityQueue
public int secondaryFirst()
IndirectDoublePriorityQueue
secondaryFirst
in interface IndirectDoublePriorityQueue<Double>
public int secondaryLast()
IndirectDoublePriorityQueue
secondaryLast
in interface IndirectDoublePriorityQueue<Double>
public int secondaryFront(int[] a)
IndirectDoublePriorityQueue
secondaryFront
in interface IndirectDoublePriorityQueue<Double>
a
- an array large enough to hold the secondary front (e.g., at least long as the reference array).
a
).IndirectPriorityQueue.front(int[])
public void changed()
DoubleHeapSemiIndirectPriorityQueue
The caller must guarantee that when this method is called the index of the first element appears just once in the queue. Failure to do so will bring the queue in an inconsistent state, and will cause unpredictable behaviour.
changed
in interface IndirectPriorityQueue<Double>
changed
in class DoubleHeapSemiIndirectPriorityQueue
public void allChanged()
DoubleHeapSemiIndirectPriorityQueue
allChanged
in interface IndirectPriorityQueue<Double>
allChanged
in class DoubleHeapSemiIndirectPriorityQueue
public void clear()
IndirectPriorityQueue
clear
in interface IndirectPriorityQueue<Double>
clear
in class DoubleHeapSemiIndirectPriorityQueue
public void trim()
DoubleHeapSemiIndirectPriorityQueue.size()
elements.
trim
in class DoubleHeapSemiIndirectPriorityQueue
public DoubleComparator secondaryComparator()
secondaryComparator
in interface DoubleIndirectDoublePriorityQueue
secondaryComparator
in interface IndirectDoublePriorityQueue<Double>
secondaryFirst()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |