void PairHeap<Etype>::DeleteMin( Etype & X ) { EXCEPTION( IsEmpty( ), "Pairing heap is empty" ); PairNode<Etype> *OldRoot = Root; X = Root->Element; if( Root->LeftChild == NULL ) Root = NULL; else Root = CombineSiblings( Root->LeftChild ); delete OldRoot; CurrentSize--; }
/* START: fig12_55.txt */ PairHeap DeleteMin( ElementType *MinItem, PairHeap H ) { Position NewRoot = NULL; if( IsEmpty( H ) ) Error( "Pairing heap is empty!" ); else { *MinItem = H->Element; if( H->LeftChild != NULL ) NewRoot = CombineSiblings( H->LeftChild ); free( H ); } return NewRoot; }