public class BinomialMinPQ<Key> extends Object implements Iterable<Key>
Constructor and Description |
---|
BinomialMinPQ()
Initializes an empty priority queue
Worst case is O(1)
|
BinomialMinPQ(Comparator<Key> C)
Initializes an empty priority queue using the given Comparator
Worst case is O(1)
|
BinomialMinPQ(Comparator<Key> C,
Key[] a)
Initializes a priority queue with given keys using the given Comparator
Worst case is O(n*log(n))
|
BinomialMinPQ(Key[] a)
Initializes a priority queue with given keys
Worst case is O(n*log(n))
|
Modifier and Type | Method and Description |
---|---|
Key |
delMin()
Deletes the minimum key
Worst case is O(log(n))
|
void |
insert(Key key)
Puts a Key in the heap
Worst case is O(log(n))
|
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))
hasNext() : Worst case is O(1)
|
Key |
minKey()
Get the minimum key currently in the queue
Worst case is O(log(n))
|
int |
size()
Number of elements currently on the priority queue
Worst case is O(log(n))
|
BinomialMinPQ<Key> |
union(BinomialMinPQ<Key> heap)
Merges two Binomial heaps together
This operation is destructive
Worst case is O(log(n))
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public BinomialMinPQ()
public BinomialMinPQ(Comparator<Key> C)
C
- a comparator over the keyspublic BinomialMinPQ(Key[] a)
a
- an array of keyspublic BinomialMinPQ(Comparator<Key> C, Key[] a)
C
- a comparator over the keysa
- an array of keyspublic boolean isEmpty()
public int size()
ArithmeticException
- if there are more than 2^63-1 elements in the queuepublic 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 BinomialMinPQ<Key> union(BinomialMinPQ<Key> heap)
heap
- a Binomial Heap to be merged with the current heapIllegalArgumentException
- if the heap in parameter is null