**fig7_10.txt** /* 1*/ // Left_Pos = start of left half. /* 2*/ // Right_Pos = start of right half. /* 3*/ template /* 4*/ void /* 5*/ Merge( Etype A[ ], Etype Tmp_Array[ ], unsigned int Left_Pos, /* 6*/ unsigned int Right_Pos, unsigned int Right_End ) /* 7*/ { /* 8*/ int Left_End = Right_Pos - 1; /* 9*/ int Tmp_Pos = Left_Pos; /*10*/ int Num_Elements = Right_End - Left_Pos + 1; /*11*/ // Main loop. /*12*/ while( Left_Pos <= Left_End && Right_Pos <= Right_End ) /*13*/ if( A[ Left_Pos ] <= A[ Right_Pos ] ) /*14*/ Tmp_Array[ Tmp_Pos++ ] = A[ Left_Pos++ ]; /*15*/ else /*16*/ Tmp_Array[ Tmp_Pos++ ] = A[ Right_Pos++ ]; /*17*/ while( Left_Pos <= Left_End ) // Copy rest of first half. /*18*/ Tmp_Array[ Tmp_Pos++ ] = A[ Left_Pos++ ]; /*19*/ while( Right_Pos <= Right_End ) // Copy rest of second half. /*20*/ Tmp_Array[ Tmp_Pos++ ] = A[ Right_Pos++ ]; /*21*/ // Copy Tmp_Array back. /*22*/ for( int i = 1; i <= Num_Elements; i++, Right_End-- ) /*23*/ A[ Right_End ] = Tmp_Array[ Right_End ]; /*24*/ }