Source of 27.16.java


  1: /** @author Frank M. Carrano, Timothy M. Henry
  2:     @version 5.0 */
  3: public MaxHeap(T[] entries)
  4: {
  5:    this(entries.length); // Call other constructor
  6:    lastIndex = entries.length;
  7:    // Assertion: integrityOK = true

  9:    // Copy given array to data field
 10:    for (int index = 0; index < entries.length; index++)
 11:       heap[index + 1] = entries[index];

 13:    // Create heap
 14:    for (int rootIndex = lastIndex / 2; rootIndex > 0; rootIndex--)
 15:       reheap(rootIndex);
 16: } // end constructor