public class MultiwayMinPQ<Key> extends Object implements Iterable<Key>
Constructor and Description |
---|
MultiwayMinPQ(Comparator<Key> comparator,
int d)
Initializes an empty priority queue
Worst case is O(d)
|
MultiwayMinPQ(Comparator<Key> comparator,
Key[] a,
int d)
Initializes a priority queue with given indexes
Worst case is O(a*log-d(n))
|
MultiwayMinPQ(int d)
Initializes an empty priority queue
Worst case is O(d)
|
MultiwayMinPQ(Key[] a,
int d)
Initializes a priority queue with given indexes
Worst case is O(n*log-d(n))
|
Modifier and Type | Method and Description |
---|---|
Key |
delMin()
Deletes the minimum key
Worst case is O(d*log-d(n))
|
void |
insert(Key key)
Puts a Key on the priority queue
Worst case is O(log-d(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(d*log-d(n))
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)
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public MultiwayMinPQ(int d)
d
- dimension of the heapIllegalArgumentException
- if d < 2
public MultiwayMinPQ(Comparator<Key> comparator, int d)
d
- dimension of the heapcomparator
- a Comparator over the keysIllegalArgumentException
- if d < 2
public MultiwayMinPQ(Key[] a, int d)
d
- dimension of the heapa
- an array of keysIllegalArgumentException
- if d < 2
public MultiwayMinPQ(Comparator<Key> comparator, Key[] a, int d)
d
- dimension of the heapcomparator
- a Comparator over the keysa
- an array of keysIllegalArgumentException
- if d < 2
public 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 empty