Source of 26.16.java


  1: public MaxHeap(T[] entries)
  2: {
  3:    this(entries.length); // Call previous constructor
  4:    assert initialized = true;
  5: 
  6:    // Copy given array to data field
  7:    for (int index = 0; index < entries.length; index++)
  8:       heap[index + 1] = entries[index];
  9: 
 10:    // Create heap
 11:    for (int rootIndex = lastIndex / 2; rootIndex > 0; rootIndex--)
 12:       reheap(rootIndex);
 13: } // end constructor
 14: // Version 4.0