title: Java creating a HeapPriorityQueue using binary heap to implement PriorityQueue
body: <p>I am trying to create a HeapPriorityQueue class that implements the PriorityQueue interface using binary heap. Without using the Java Collections' PriorityQueue. </p>
  
  <p>The HeapPriorityQueue class will be ran by this driver class:</p>
  
  <pre><code>public class HeapPriorityQueueDriver {
  
      public static void main(String[] args) {
          PriorityQueue&lt;Integer, String&gt; queue = new HeapPriorityQueue&lt;Integer, String&gt;();
          queue.insert(0, "Zero");
          queue.insert(10, "Ten");
          queue.insert(1, "One");
          queue.insert(5, "Five");
          queue.insert(3, "Three");
          queue.insert(7, "Seven");
          queue.insert(9, "Nine");
  
          while(!queue.isEmpty()) {
              System.out.println(queue.extractMax());
          } // end while
      } // end main
  }
  </code></pre>
  
  <p>The output of the program should be. </p>
  
  <p>(1,One)
  (3,Three)
  (5,Five)
  (7,Seven)
  (9,Nine)
  (10,Ten)</p>
  
  <p>This is the class I tried making:</p>
  
  <p>HeapPriorityQueue (referenced)</p>
  
  <pre><code>public class HeapPriorityQueue&lt;Integer, String&gt; {
      /**
       * Construct the binary heap.
       */
      public HeapPriorityQueue( )
      {
          currentSize = 0;
          array = new Comparable[ DEFAULT_CAPACITY + 1 ];
      }
  
      /**
       * Construct the binary heap from an array.
       * @param items the inital items in the binary heap.
       */
      public HeapPriorityQueue( Comparable [ ] K )
      {
          currentSize = K.length;
          array = new Comparable[ K.length + 1 ];
  
          for( int i = 0; i &lt; K.length; i++ )
              array[ i + 1 ] = K[ i ];
          buildHeap( );    
      }
  
      /**
       * Remove the smallest item from the priority queue.
       * @return the smallest item.
       * @throws UnderflowException if empty.
       */
      public Comparable deleteMin( )
      {
          Comparable minK = findMin( );
          array[ 1 ] = array[ currentSize-- ];
          percolateDown( 1 );
  
          return minK;
      }
  
      private Comparable findMin() {
          // TODO Auto-generated method stub
          return null;
      }
  
      /**
       * Establish heap order property from an arbitrary
       * arrangement of items. Runs in linear time.
       */
      private void buildHeap( )
      {
          for( int i = currentSize / 2; i &gt; 0; i-- )
              percolateDown( i );
      }
  
      /**
       * Returns size.
       * @return current size.
       */
      public int size( )
      {
          return currentSize;
      }
  
      /**
       * Make the priority queue logically empty.
       */
      public void makeEmpty( )
      {
          currentSize = 0;
      }
  
      private static final int DEFAULT_CAPACITY = 100;
  
      private int currentSize;      // Number of elements in heap
      private Comparable [ ] array; // The heap array
  
      /**
       * Internal method to percolate down in the heap.
       * @param hole the index at which the percolate begins.
       */
      private void percolateDown( int hole )
      {
          int child;
          Comparable tmp = array[ hole ];
  
          for( ; hole * 2 &lt;= currentSize; hole = child )
          {
              child = hole * 2;
              if( child != currentSize &amp;&amp;
                      array[ child + 1 ].compareTo( array[ child ] ) &lt; 0 )
                  child++;
              if( array[ child ].compareTo( tmp ) &lt; 0 )
                  array[ hole ] = array[ child ];
              else
                  break;
          }
          array[ hole ] = tmp;
      }
  
      /**
       * Internal method to extend array.
       */
      private void doubleArray( )
      {
          Comparable [ ] newArray;
  
          newArray = new Comparable[ array.length * 2 ];
          for( int i = 0; i &lt; array.length; i++ )
              newArray[ i ] = array[ i ];
          array = newArray;
      }
  }
  </code></pre>
  
  <p>Error Line in Console: "Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
      Type mismatch: cannot convert from HeapPriorityQueue to PriorityQueue</p>
  
  <pre><code>at HeapPriorityQueueDriver.main(HeapPriorityQueueDriver.java:5)"
  </code></pre>
  
  <p>Can anybody help me solve this?</p>