For the function to yield the expected result, the elements of each of both ranges shall already be ordered (independently for each range) according to the same strict weak ordering criterion used by this function (operator< or comp). The resulting range is also sorted according to it.
Parameters
- first
- Bidirectional iterator to the initial position in the first sequence to be merged. This is also the initial position of where the resulting merged range is stored.
- middle
- Bidirectional iterator to the initial position of the second sequence, which because both sequences must be consecutive, matches the past-the-end position of the first sequence.
- last
- Bidirectional iterator to the final position of the second sequence. This is also the final position in the resulting merged range is stored.
Return value
noneExample
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
Output:
The resulting vector contains: 5 10 10 15 20 20 25 30 40 50 |
Complexity
Linear in comparisons (N-1) if an internal buffer was used, NlogN otherwise (where N is the number elements in the range [first,last)).See also
| merge | Merge sorted ranges (function template) |
| partition | Partition range in two (function template) |
| includes | Test whether sorted range includes another sorted range (function template) |
