Algorithms to compare ranges and elements.
More...
Detailed Description
Algorithms to compare ranges and elements.
Tests for eqaulity of ranges and comparisons of ranges are included, as well as tests for finding the maximum or minimum of two elements.
- See also:
- OLAlgorithm
Function Documentation
Test whether two ranges are equal.
This message sends the message equalFrom:to:with:predicate: using OLEqualTo as the predicate.
- Parameters:
-
first | the first in the range of elements to test |
last | one position beyond the last in the range of elements to test |
first2 | the first in the second range to test |
- Returns:
- YES if the ranges are equal, NO otherwise
Test whether two ranges are equal.
Each element in the range [first, last)
is tested with the corresponding element from the range starting with first2 using the function object pred. If pred returns YES for each of its tests, then this message returns YES.
- Parameters:
-
first | the first in the range of elements to test |
last | one position beyond the last in the range of elements to test |
first2 | the first in the second range to test |
pred | the function object for testing |
- Returns:
- YES if the ranges are equal, NO otherwise
Compare two ranges lexicographically.
This message simply sends the message lexicographicalCompareFrom:to:andFrom:andTo:predicate: using OLLess as the predicate.
- Parameters:
-
first1 | the first in the first range of elements to test |
last1 | one position beyond the last in the first range of elements to test |
first2 | the first in the second range of elements to test |
last2 | one position beyond the last in the second range of elements to test |
- Returns:
- YES if the elements in the first range satisfy the elements when compared to corresponding elements in the second range, NO otherwise
Compare two ranges lexicographically.
A lexicographical comparison is one where each of the elements in the range [first1, last1)
is compared with each of the elements in the range [first2, last2)
. If each element in the first range satisfies the predicate pred when compared to its corresponding element in the second range, then YES is returned.
- Parameters:
-
first1 | the first in the first range of elements to test |
last1 | one position beyond the last in the first range of elements to test |
first2 | the first in the second range of elements to test |
last2 | one position beyond the last in the second range of elements to test |
pred | the predicate used to compare elements in the two ranges |
- Returns:
- YES if the elements in the first range satisfy the elements when compared to corresponding elements in the second range, NO otherwise
+ (id) max: |
|
(id) |
left |
or: |
|
(id) |
right |
|
|
| |
Return the maximum of two elements.
This message simply sends the message max:or:predicate: using OLLess as the predicate.
- Parameters:
-
left | the first element to compare |
right | the second element to compare |
- Returns:
- the element that is the maximum element according to OLLess
Return the maximum of two elements.
The two elements are compared using the predicate pred with left passed as the first argument to the predicate and right passed as the second argument. If the predicate returns YES, then right is returned, otherwise left is returned.
- Parameters:
-
left | the first element to compare |
right | the second element to compare |
pred | the predicate that is used to compare the two objects |
- Returns:
- the element that is the maximum element according to pred
+ (id) min: |
|
(id) |
left |
or: |
|
(id) |
right |
|
|
| |
Return the minimum of two elements.
This message simply sends the message min:or:predicate: using OLLess as the predicate.
- Parameters:
-
left | the first element to compare |
right | the second element to compare |
- Returns:
- the element that is the minimum element according to OLLess
Return the minimum of two elements.
The two elements are compared using the predicate pred with left passed as the first argument to the predicate and right passed as the second argument. If the predicate returns YES, then left is returned, otherwise right is returned.
- Parameters:
-
left | the first element to compare |
right | the second element to compare |
pred | the predicate that is used to compare the two objects |
- Returns:
- the element that is the minimum element according to pred