public final class FibonacciHeap<T>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
FibonacciHeap.Entry<T> |
Constructor and Description |
---|
FibonacciHeap() |
Modifier and Type | Method and Description |
---|---|
void |
decreaseKey(FibonacciHeap.Entry<T> entry,
double newPriority)
Decreases the key of the specified element to the new priority.
|
void |
delete(FibonacciHeap.Entry<T> entry)
Deletes this Entry from the Fibonacci heap that contains it.
|
FibonacciHeap.Entry<T> |
dequeueMin()
Dequeues and returns the minimum element of the Fibonacci heap.
|
FibonacciHeap.Entry<T> |
enqueue(T value,
double priority)
Inserts the specified element into the Fibonacci heap with the specified
priority.
|
boolean |
isEmpty()
Returns whether the heap is empty.
|
static <T> FibonacciHeap<T> |
merge(FibonacciHeap<T> one,
FibonacciHeap<T> two)
Given two Fibonacci heaps, returns a new Fibonacci heap that contains
all of the elements of the two heaps.
|
FibonacciHeap.Entry<T> |
min()
Returns an Entry object corresponding to the minimum element of the
Fibonacci heap, throwing a NoSuchElementException if the heap is
empty.
|
int |
size()
Returns the number of elements in the heap.
|
public FibonacciHeap.Entry<T> enqueue(T value, double priority)
value
- The value to insert.priority
- Its priority, which must be valid.public FibonacciHeap.Entry<T> min()
java.util.NoSuchElementException
- If the heap is empty.public boolean isEmpty()
public int size()
public static <T> FibonacciHeap<T> merge(FibonacciHeap<T> one, FibonacciHeap<T> two)
one
- The first Fibonacci heap to merge.two
- The second Fibonacci heap to merge.public FibonacciHeap.Entry<T> dequeueMin()
java.util.NoSuchElementException
- If the heap is empty.public void decreaseKey(FibonacciHeap.Entry<T> entry, double newPriority)
entry
- The element whose priority should be decreased.newPriority
- The new priority to associate with this entry.java.lang.IllegalArgumentException
- If the new priority exceeds the old
priority, or if the argument is not a finite double.public void delete(FibonacciHeap.Entry<T> entry)
entry
- The entry to delete.