merge [C++ Reference]
Keywords: stl,algorithm,merge
Date: 2009-10-09T01:55:23-0700

[[merge]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## 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

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •