|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--gov.nist.antd.merlin.algorithm.route.util.PairingHeap
This class is the representation of queue
This class was developed at the National Institute of Standards and Technology by employees of the Federal Government in the course of their official duties. Pursuant to title 17 Section 105 of the United States Code this software is not subject to copyright protection and is in the public domain. NIST assumes no responsibility whatsoever for its use by other parties, and makes no guarantees, expressed or implied, about its quality, reliability, or any other characteristic.
We would appreciate acknowledgement if the software is used.
NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
| Nested Class Summary | |
private static class |
PairingHeap.PairNode
Private static class for use with PairHeap. |
| Nested classes inherited from class gov.nist.antd.merlin.algorithm.route.util.PriorityQueue |
|
| Field Summary | |
private PairingHeap.PairNode |
root
The root noot the the pairing heap |
private int |
theSize
The current size |
private PairingHeap.PairNode[] |
treeArray
The tree array for combineSiblings |
| Constructor Summary | |
PairingHeap()
Construct the pairing heap. |
|
| Method Summary | |
private PairingHeap.PairNode |
combineSiblings(PairingHeap.PairNode firstSibling)
Internal method that implements two-pass merging. |
private PairingHeap.PairNode |
compareAndLink(PairingHeap.PairNode first,
PairingHeap.PairNode second)
Internal method that is the basic operation to maintain order. |
void |
decreaseKey(PriorityQueue.Position pos,
java.lang.Comparable newVal)
Change the value of the item stored in the pairing heap. |
java.lang.Comparable |
deleteMin()
Remove the smallest item from the priority queue. |
private PairingHeap.PairNode[] |
doubleIfFull(PairingHeap.PairNode[] array,
int index)
Double the size of the Heap full |
java.lang.Comparable |
findMin()
Find the smallest item in the priority queue. |
PriorityQueue.Position |
insert(java.lang.Comparable x)
Insert into the priority queue, and return a Position that can be used by decreaseKey. |
boolean |
isEmpty()
Test if the priority queue is logically empty. |
void |
makeEmpty()
Make the priority queue logically empty. |
int |
size()
Returns number of items stored in the priority queue. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private PairingHeap.PairNode root
private int theSize
private PairingHeap.PairNode[] treeArray
| Constructor Detail |
public PairingHeap()
| Method Detail |
public PriorityQueue.Position insert(java.lang.Comparable x)
insert in interface PriorityQueuex - the item to insert.
public java.lang.Comparable findMin()
findMin in interface PriorityQueueUnderflowException - if pairing heap is empty.public java.lang.Comparable deleteMin()
deleteMin in interface PriorityQueueUnderflowException - if pairing heap is empty.
public void decreaseKey(PriorityQueue.Position pos,
java.lang.Comparable newVal)
decreaseKey in interface PriorityQueuepos - any Position returned by insert.newVal - the new value, which must be smaller
than the currently stored value.
java.lang.IllegalArgumentException - if pos is null.
IllegalValueException - if new value is larger than old.public boolean isEmpty()
isEmpty in interface PriorityQueuepublic int size()
size in interface PriorityQueuepublic void makeEmpty()
makeEmpty in interface PriorityQueue
private PairingHeap.PairNode compareAndLink(PairingHeap.PairNode first,
PairingHeap.PairNode second)
first - root of tree 1, which may not be null.
first.nextSibling MUST be null on entry.second - root of tree 2, which may be null.
private PairingHeap.PairNode[] doubleIfFull(PairingHeap.PairNode[] array,
int index)
array - The list of PairNodeindex - The index of the top element
private PairingHeap.PairNode combineSiblings(PairingHeap.PairNode firstSibling)
firstSibling - the root of the conglomerate;
assumed not null.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||