it.unimi.dsi.fastutil.longs
Class LongArrayIndirectDoublePriorityQueue

java.lang.Object
  extended by it.unimi.dsi.fastutil.AbstractIndirectPriorityQueue<Long>
      extended by it.unimi.dsi.fastutil.longs.LongArrayIndirectPriorityQueue
          extended by it.unimi.dsi.fastutil.longs.LongArrayIndirectDoublePriorityQueue
All Implemented Interfaces:
IndirectDoublePriorityQueue<Long>, IndirectPriorityQueue<Long>, LongIndirectDoublePriorityQueue, LongIndirectPriorityQueue

public class LongArrayIndirectDoublePriorityQueue
extends LongArrayIndirectPriorityQueue
implements LongIndirectDoublePriorityQueue

A type-specific array-based indirect double priority queue.

Instances of this class are based on a single array. This implementation is extremely inefficient, but it is difficult to beat when the size of the queue is very small. The array is enlarged as needed, but it is never shrunk. Use the LongArrayIndirectPriorityQueue.trim() method to reduce its 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
LongArrayIndirectDoublePriorityQueue(long[] refArray)
          Creates a new empty queue with capacity equal to the length of the reference array and natural order as primary comparator.
LongArrayIndirectDoublePriorityQueue(long[] refArray, int capacity)
          Creates a new empty queue with a given capacity and natural order as primary comparator.
LongArrayIndirectDoublePriorityQueue(long[] refArray, int[] a)
          Wraps a given array in a queue using the natural order and its opposite.
LongArrayIndirectDoublePriorityQueue(long[] refArray, int[] a, int size)
          Wraps a given array in a queue using the natural order and its opposite.
LongArrayIndirectDoublePriorityQueue(long[] refArray, int[] a, int size, LongComparator c)
          Wraps a given array in a queue using a given comparator and its opposite.
LongArrayIndirectDoublePriorityQueue(long[] refArray, int[] a, int size, LongComparator c, LongComparator d)
          Wraps a given array in a queue using the given comparators.
LongArrayIndirectDoublePriorityQueue(long[] refArray, int[] a, LongComparator c)
          Wraps a given array in a queue using a given comparator and its opposite.
LongArrayIndirectDoublePriorityQueue(long[] refArray, int[] a, LongComparator c, LongComparator d)
          Wraps a given array in a queue using the given comparators.
LongArrayIndirectDoublePriorityQueue(long[] refArray, int capacity, LongComparator c)
          Creates a new empty queue with a given capacity.
LongArrayIndirectDoublePriorityQueue(long[] refArray, int capacity, LongComparator c, LongComparator d)
          Creates a new empty queue with a given capacity.
LongArrayIndirectDoublePriorityQueue(long[] refArray, LongComparator c)
          Creates a new empty queue with capacity equal to the length of the reference array.
LongArrayIndirectDoublePriorityQueue(long[] refArray, LongComparator c, LongComparator d)
          Creates a new empty queue with capacity equal to the length of the reference array.
 
Method Summary
 void changed(int i)
          Notifies the queue that the specified element has changed (optional operation).
 LongComparator 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).
 
Methods inherited from class it.unimi.dsi.fastutil.longs.LongArrayIndirectPriorityQueue
allChanged, changed, clear, comparator, dequeue, enqueue, first, front, last, remove, size, toString, trim
 
Methods inherited from class it.unimi.dsi.fastutil.AbstractIndirectPriorityQueue
isEmpty
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface it.unimi.dsi.fastutil.longs.LongIndirectPriorityQueue
comparator
 
Methods inherited from interface it.unimi.dsi.fastutil.IndirectPriorityQueue
allChanged, changed, clear, dequeue, enqueue, first, front, isEmpty, last, remove, size
 

Constructor Detail

LongArrayIndirectDoublePriorityQueue

public LongArrayIndirectDoublePriorityQueue(long[] refArray,
                                            int capacity,
                                            LongComparator c,
                                            LongComparator d)
Creates a new empty queue with a given capacity.

Parameters:
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.

LongArrayIndirectDoublePriorityQueue

public LongArrayIndirectDoublePriorityQueue(long[] refArray,
                                            int capacity,
                                            LongComparator c)
Creates a new empty queue with a given capacity.

This constructor uses as secondary comparator the opposite order of c.

Parameters:
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.

LongArrayIndirectDoublePriorityQueue

public LongArrayIndirectDoublePriorityQueue(long[] refArray,
                                            int capacity)
Creates a new empty queue with a given capacity and natural order as primary comparator.

This constructor uses as secondary comparator the opposite of the natural order.

Parameters:
refArray - the reference array.
capacity - the initial capacity of this queue.

LongArrayIndirectDoublePriorityQueue

public LongArrayIndirectDoublePriorityQueue(long[] refArray,
                                            LongComparator c,
                                            LongComparator d)
Creates a new empty queue with capacity equal to the length of the reference array.

Parameters:
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.

LongArrayIndirectDoublePriorityQueue

public LongArrayIndirectDoublePriorityQueue(long[] refArray,
                                            LongComparator c)
Creates a new empty queue with capacity equal to the length of the reference array.

This constructor uses as secondary comparator the opposite order of c.

Parameters:
refArray - the reference array.
c - the primary comparator used in this queue, or null for the natural order.

LongArrayIndirectDoublePriorityQueue

public LongArrayIndirectDoublePriorityQueue(long[] refArray)
Creates a new empty queue with capacity equal to the length of the reference array and natural order as primary comparator.

This constructor uses as secondary comparator the opposite of the natural order.

Parameters:
refArray - the reference array.

LongArrayIndirectDoublePriorityQueue

public LongArrayIndirectDoublePriorityQueue(long[] refArray,
                                            int[] a,
                                            int size,
                                            LongComparator c,
                                            LongComparator d)
Wraps a given array in a queue using the given comparators.

The queue returned by this method will be backed by the given array.

Parameters:
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.

LongArrayIndirectDoublePriorityQueue

public LongArrayIndirectDoublePriorityQueue(long[] refArray,
                                            int[] a,
                                            LongComparator c,
                                            LongComparator d)
Wraps a given array in a queue using the given comparators.

The queue returned by this method will be backed by the given array.

Parameters:
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.

LongArrayIndirectDoublePriorityQueue

public LongArrayIndirectDoublePriorityQueue(long[] refArray,
                                            int[] a,
                                            int size,
                                            LongComparator c)
Wraps a given array in a queue using a given comparator and its opposite.

The queue returned by this method will be backed by the given array.

Parameters:
refArray - the reference array.
a - an array of indices into refArray.
size - the number of elements to be included in the queue.
c - the comparator used in this queue, or null for the natural order.

LongArrayIndirectDoublePriorityQueue

public LongArrayIndirectDoublePriorityQueue(long[] refArray,
                                            int[] a,
                                            LongComparator c)
Wraps a given array in a queue using a given comparator and its opposite.

The queue returned by this method will be backed by the given array.

Parameters:
refArray - the reference array.
a - an array of indices into refArray.
c - the comparator used in this queue, or null for the natural order.

LongArrayIndirectDoublePriorityQueue

public LongArrayIndirectDoublePriorityQueue(long[] refArray,
                                            int[] a,
                                            int size)
Wraps a given array in a queue using the natural order and its opposite.

The queue returned by this method will be backed by the given array.

Parameters:
refArray - the reference array.
a - an array of indices into refArray.
size - the number of elements to be included in the queue.

LongArrayIndirectDoublePriorityQueue

public LongArrayIndirectDoublePriorityQueue(long[] refArray,
                                            int[] a)
Wraps a given array in a queue using the natural order and its opposite.

The queue returned by this method will be backed by the given array.

Parameters:
refArray - the reference array.
a - an array of indices into refArray.
Method Detail

secondaryFirst

public int secondaryFirst()
Description copied from interface: IndirectDoublePriorityQueue
Returns the first element of this queue with respect to the secondary comparator.

Specified by:
secondaryFirst in interface IndirectDoublePriorityQueue<Long>
Returns:
the first element of this queue w.r.t. the secondary comparator.

secondaryLast

public int secondaryLast()
Description copied from interface: IndirectDoublePriorityQueue
Returns the last element of this queue with respect to the secondary comparator (optional operation).

Specified by:
secondaryLast in interface IndirectDoublePriorityQueue<Long>
Returns:
the last element of this queue w.r.t. the secondary comparator.

secondaryFront

public int secondaryFront(int[] a)
Description copied from interface: IndirectDoublePriorityQueue
Retrieves the secondary front of the queue in a given array (optional operation).

Specified by:
secondaryFront in interface IndirectDoublePriorityQueue<Long>
Parameters:
a - an array large enough to hold the secondary front (e.g., at least long as the reference array).
Returns:
the number of elements actually written (starting from the first position of a).
See Also:
IndirectPriorityQueue.front(int[])

changed

public void changed(int i)
Description copied from class: LongArrayIndirectPriorityQueue
Notifies the queue that the specified element has changed (optional operation).

Note that the specified element must belong to the queue.

Note that for efficiency reasons this method will not throw an exception when index is not in the queue.

Specified by:
changed in interface IndirectPriorityQueue<Long>
Overrides:
changed in class LongArrayIndirectPriorityQueue
Parameters:
i - the element that has changed.

secondaryComparator

public LongComparator secondaryComparator()
Returns the secondary comparator of this queue.

Specified by:
secondaryComparator in interface IndirectDoublePriorityQueue<Long>
Specified by:
secondaryComparator in interface LongIndirectDoublePriorityQueue
Returns:
the secondary comparator of this queue.
See Also:
secondaryFirst()