Algorithms for merging.
More...
Detailed Description
Algorithms for merging.
Merging is the process of combining two sorted ranges into one sorted range. All merge algorithms provide stable merges, meaning that equivilent elements in the input ranges remain in the same relative order after the merge is done.
- See also:
- OLAlgorithm
Function Documentation
Merge two consecutive ranges.
This message simply sends the message inPlaceMergeFrom:middle:to:predicate: using OLLess as the predicate.
- Precondition:
- Both
[first, middle)
and [middle, last)
must be sorted in the order defined by OLLess.
- Parameters:
-
first | the first position in the first range |
middle | one position beyond the last in the first range and the first position in the second range |
last | one position beyond the last in the second range |
Merge two consecutive ranges.
The sorted range [first, middle)
is merged with the sorted range [middle, last)
to create a single sorted range [first, last)
. The merge is a stable merge, meaning that the equivilent elements in each of the two ranges remain in the same relative order after the merge is done.
- Precondition:
- Both
[first, middle)
and [middle, last)
must be sorted in the order defined by the predicate pred.
- Parameters:
-
first | the first position in the first range |
middle | one position beyond the last in the first range and the first position in the second range |
last | one position beyond the last in the second range |
pred | the predicate that indicates the sorting order |
Merge two sorted ranges.
This message simply sends the message mergeFrom:to:andFrom:andTo:destination:predicate: using OLLess as the predicate.
- Precondition:
- The ranges
[first1, last1)
and [first2, last2)
must be sorted in the order defined by OLLess.
- The range starting from dest must either have enough valid elements to hold the result, or dest be a type of insert iterator.
- Parameters:
-
first1 | the first position in the first range |
last1 | one position beyond the last in the first range |
first2 | the first position in the second range |
last2 | one position beyond the last in the second range |
dest | the first element in the range to which to copy the merged elements |
- Returns:
- an iterator pointing to one position beyond the last element in the resulting range that starts from dest.
Merge two sorted ranges.
The sorted range [first1, last1)
is merged with the sorted range [first2, last2)
and copied to the location indicated by dest. The resulting range starting at dest will be sorted using the order defined by pred. An iterator pointing to one position beyond the last element in the destination range is returned. The merge is stable, meaning that equivilent elements in the each of the two ranges remain in the same relative order after the merge is done.
- Precondition:
- The ranges
[first1, last1)
and [first2, last2)
must be sorted in the order defined by pred.
- The range starting from dest must either have enough valid elements to hold the result, or dest be a type of insert iterator.
- Note:
- If OpenStep is present the returned object will be autoreleased before being returned.
- Parameters:
-
first1 | the first position in the first range |
last1 | one position beyond the last in the first range |
first2 | the first position in the second range |
last2 | one position beyond the last in the second range |
dest | the first element in the range to which to copy the merged elements |
pred | the predicate that indicates the sorting order |
- Returns:
- an iterator pointing to one position beyond the last element in the resulting range that starts from dest.