public void displayHeap() {
    System.out.println("heapArray: "); // array format
    for (int m = 0; m < currentSize; m++)
      if (heapArray[m] != null)
        System.out.println(heapArray[m].getKey() + " ");
      else
        System.out.print("-- ");
    int nBlanks = 32;
    int itemsPerRow = 1;
    int column = 0;
    int j = 0; // current item

    while (currentSize > 0) // for each heap item
    {
      if (column == 0) // first item in row?
        for (int k = 0; k < nBlanks; k++)
          // preceding blanks
          System.out.print(' ');
      // display item
      System.out.print(heapArray[j].getKey());

      if (++j == currentSize) // done?
        break;

      if (++column == itemsPerRow) // end of row?
      {
        nBlanks /= 2; // half the blanks
        itemsPerRow *= 2; // twice the items
        column = 0; // start over on
        System.out.println(); //    new row
      } else
        // next item on row
        for (int k = 0; k < nBlanks * 2 - 2; k++)
          System.out.print(' '); // interim blanks
    } 
  }