merge

Syntax:

    #include <algorithm>
    output_iterator merge( input_iterator start1, input_iterator end1, input_iterator2 start2, input_iterator2 end2, output_iterator result );
    output_iterator merge( input_iterator start1, input_iterator end1, input_iterator2 start2, input_iterator2 end2, output_iterator result, StrictWeakOrdering cmp );

The merge() function combines two sorted ranges [start1,end1) and [start2,end2) into a single sorted range, stored starting at result. The return value of this function is an iterator to the end of the merged range.

If the strict weak ordering function object cmp is given, then it is used in place of the < operator to perform comparisons between elements.

merge() runs in linear time.

Related Topics: inplace_merge, set_union, sort