Package algs24
Class XFixedMinPQ<K extends Comparable<? super K>>
java.lang.Object
algs24.XFixedMinPQ<K>
- All Implemented Interfaces:
Iterable<K>
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionXFixedMinPQ(int initCapacity) Create an empty priority queue with the given initial capacity, using the given comparator. -
Method Summary
Modifier and TypeMethodDescriptiondelMin()Delete and return the smallest key on the priority queue.private voidexch(int i, int j) private booleangreater(int i, int j) voidAdd a new key to the priority queue.booleanisEmpty()Is the priority queue empty?booleanisFull()Is the priority queue full?private booleanprivate booleanisMinHeap(int k) iterator()Return an iterator that iterates over all of the keys on the priority queue in ascending order.static voidA test client.min()Return the smallest key on the priority queue.private voidshowHeap()private voidsink(int k) intsize()Return the number of items on the priority queue.private voidswim(int k) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
pq
-
N
-
MAXN
-
-
Constructor Details
-
XFixedMinPQ
Create an empty priority queue with the given initial capacity, using the given comparator.
-
-
Method Details
-
isEmpty
Is the priority queue empty? -
isFull
Is the priority queue full? -
size
Return the number of items on the priority queue. -
min
Return the smallest key on the priority queue. Throw an exception if the priority queue is empty. -
insert
Add a new key to the priority queue. -
delMin
Delete and return the smallest key on the priority queue. Throw an exception if the priority queue is empty. -
swim
-
sink
-
greater
-
exch
-
isMinHeap
-
isMinHeap
-
iterator
Return an iterator that iterates over all of the keys on the priority queue in ascending order.The iterator doesn't implement
remove()since it's optional.- Specified by:
iteratorin interfaceIterable<K extends Comparable<? super K>>
-
showHeap
-
main
A test client.
-