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 Link icon

    Constructors
    Constructor
    Description
    Create an empty priority queue
  • Method Summary Link icon

    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 Link icon

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

    • MyPtrHeap Link icon

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

    • isEmpty Link icon

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

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

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

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

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

      public static void main(String[] args)