Package algs24
Class XFixedMaxPQ<K extends Comparable<? super K>>
java.lang.Object
algs24.XFixedMaxPQ<K>
- All Implemented Interfaces:
Iterable<K>
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondelMax()
Delete and return the largest key on the priority queue.private void
exch
(int i, int j) void
Add a new key to the priority queue.boolean
isEmpty()
Is the priority queue empty?boolean
isFull()
Is the priority queue full?private boolean
private boolean
isMaxHeap
(int k) iterator()
Return an iterator that iterates over all of the keys on the priority queue in descending order.private boolean
less
(int i, int j) static void
A test client.max()
Return the largest key on the priority queue.private void
showHeap()
private void
sink
(int k) int
size()
Return the number of items on the priority queue.private void
swim
(int k) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
pq
-
N
-
MAXN
-
-
Constructor Details
-
XFixedMaxPQ
-
-
Method Details
-
isEmpty
Is the priority queue empty? -
isFull
Is the priority queue full? -
size
Return the number of items on the priority queue. -
max
Return the largest key on the priority queue. Throw an exception if the priority queue is empty. -
insert
Add a new key to the priority queue. -
delMax
Delete and return the largest key on the priority queue. Throw an exception if the priority queue is empty. -
swim
-
sink
-
less
-
exch
-
isMaxHeap
-
isMaxHeap
-
iterator
Return an iterator that iterates over all of the keys on the priority queue in descending order.The iterator doesn't implement
remove()
since it's optional.- Specified by:
iterator
in interfaceIterable<K extends Comparable<? super K>>
-
showHeap
-
main
A test client.
-