template < class Record > class Sortable_list : public List < Record > { public : void merge_sort(); private : void recursive_merge_sort( Node < Record > * & ); Node < Record > * divide_from( Node < Record > * ); Node < Record > * maege( Node < Record > *, Node < Record > * ); };
template < class Record > void Sortable_list < Record > :: merge_sort() { recursive_merge_sort( head ) ; }
template < class Record > void Sortable_list < Record > :: recursive_merge_sort( Node < Record > * &head ) { if ( head != NULL && head -> next != NULL ) { Node < Record > * second_harf = divide_from( head ); recursive_merge_sort( head ); recursive_merge_sort( second_half ) ; head = merge ( head, second_half ) ; } }