Source of 26.12.java


  1: public T removeMax()
  2: {
  3:    checkInitialization();        // Ensure initialization of data fields
  4:    T root = null;
  5: 
  6:    if (!isEmpty())
  7:    {
  8:       root = heap[1];            // Return value
  9:       heap[1] = heap[lastIndex]; // Form a semiheap
 10:       lastIndex--;               // Decrease size
 11:       reheap(1);                 // Transform to a heap
 12:    } // end if
 13: 
 14:    return root;
 15: } // end removeMax
 16: // Version 4.0