Constructor and Description |
---|
FibonacciMinPQ()
Initializes an empty priority queue
Worst case is O(1)
|
FibonacciMinPQ(Comparator<Key> C)
Initializes an empty priority queue
Worst case is O(1)
|
FibonacciMinPQ(Comparator<Key> C,
Key[] a)
Initializes a priority queue with given keys
Worst case is O(n)
|
FibonacciMinPQ(Key[] a)
Initializes a priority queue with given keys
Worst case is O(n)
|
Modifier and Type | Method and Description |
---|---|
Key |
delMin()
Deletes the minimum key
Worst case is O(log(n)) (amortized)
|
void |
insert(Key key)
Insert a key in the queue
Worst case is O(1)
|
boolean |
isEmpty()
Whether the priority queue is empty
Worst case is O(1)
|
Iterator<Key> |
iterator()
Gets an Iterator over the Keys in the priority queue in ascending order
The Iterator does not implement the remove() method
iterator() : Worst case is O(n)
next() : Worst case is O(log(n)) (amortized)
hasNext() : Worst case is O(1)
|
Key |
minKey()
Gets the minimum key currently in the queue
Worst case is O(1)
|
int |
size()
Number of elements currently on the priority queue
Worst case is O(1)
|
FibonacciMinPQ<Key> |
union(FibonacciMinPQ<Key> that)
Merges two heaps together
This operation is destructive
Worst case is O(1)
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public FibonacciMinPQ(Comparator<Key> C)
C
- a Comparator over the Keyspublic FibonacciMinPQ()
public FibonacciMinPQ(Key[] a)
a
- an array of keyspublic FibonacciMinPQ(Comparator<Key> C, Key[] a)
C
- a comparator over the keysa
- an array of keyspublic boolean isEmpty()
public int size()
public void insert(Key key)
key
- a Keypublic Key minKey()
NoSuchElementException
- if the priority queue is emptypublic Key delMin()
NoSuchElementException
- if the priority queue is emptypublic FibonacciMinPQ<Key> union(FibonacciMinPQ<Key> that)
that
- a Fibonacci heap