Source of 27.12.java


  1: // @author Frank M. Carrano, Timothy M. Henry
  2: // @version 5.0
  3: public T removeMax()
  4: {
  5:    checkIntegrity();             // Ensure initialization of data fields
  6:    T root = null;

  8:    if (!isEmpty())
  9:    {
 10:       root = heap[1];            // Return value
 11:       heap[1] = heap[lastIndex]; // Form a semiheap
 12:       lastIndex--;               // Decrease size
 13:       reheap(1);                 // Transform to a heap
 14:    } // end if

 16:    return root;
 17: } // end removeMax