Package algs24

Class MyPtrHeap<K extends Comparable<? super K>>

java.lang.Object
algs24.MyPtrHeap<K>

public class MyPtrHeap<K extends Comparable<? super K>> extends Object
The PMytrHeap class is the priorityQ class from Question 2.4.24. It represents a priority queue of generic keys. It supports the usual insert and delete-the-maximum operations, along with methods for peeking at the maximum key, testing if the priority queue is empty, and iterating through the keys. For additional documentation, see Section 2.4 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create an empty priority queue
  • Method Summary

    Modifier and Type
    Method
    Description
    Delete and return the largest key on the priority queue.
    void
    insert(K x)
    Add a new key to the priority queue.
    boolean
    Is the priority queue empty?
    static void
    main(String[] args)
     
    max()
    Return the largest key on the priority queue.
    int
    Return the number of items on the priority queue.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MyPtrHeap

      public MyPtrHeap()
      Create an empty priority queue
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Is the priority queue empty?
    • size

      public int size()
      Return the number of items on the priority queue.
    • max

      public K max()
      Return the largest key on the priority queue. Throw an exception if the priority queue is empty.
    • insert

      public void insert(K x)
      Add a new key to the priority queue.
    • delMax

      public K delMax()
      Delete and return the largest key on the priority queue. Throw an exception if the priority queue is empty.
    • main

      public static void main(String[] args)