ObjectiveLib  1.0.0
Comparisons
Algorithms

Algorithms to compare ranges and elements. More...

Collaboration diagram for Comparisons:

Comparisons

(BOOL) + equalFrom:to:with:
 Test whether two ranges are equal.
(BOOL) + equalFrom:to:with:predicate:
 Test whether two ranges are equal.
(BOOL) + lexicographicalCompareFrom:to:andFrom:andTo:
 Compare two ranges lexicographically.
(BOOL) + lexicographicalCompareFrom:to:andFrom:andTo:predicate:
 Compare two ranges lexicographically.
(id) + max:or:
 Return the maximum of two elements.
(id) + max:or:predicate:
 Return the maximum of two elements.
(id) + min:or:
 Return the minimum of two elements.
(id) + min:or:predicate:
 Return the minimum of two elements.

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

+ (BOOL) equalFrom: (OLForwardIterator *)  first
to: (OLForwardIterator *)  last
with: (OLForwardIterator *)  first2 

Test whether two ranges are equal.

This message sends the message equalFrom:to:with:predicate: using OLEqualTo as the predicate.

Parameters:
firstthe first in the range of elements to test
lastone position beyond the last in the range of elements to test
first2the first in the second range to test
Returns:
YES if the ranges are equal, NO otherwise
+ (BOOL) equalFrom: (OLForwardIterator *)  first
to: (OLForwardIterator *)  last
with: (OLForwardIterator *)  first2
predicate: (id< OLBoolBinaryFunction >)  pred 

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:
firstthe first in the range of elements to test
lastone position beyond the last in the range of elements to test
first2the first in the second range to test
predthe function object for testing
Returns:
YES if the ranges are equal, NO otherwise
+ (BOOL) lexicographicalCompareFrom: (OLForwardIterator *)  first1
to: (OLForwardIterator *)  last1
andFrom: (OLForwardIterator *)  first2
andTo: (OLForwardIterator *)  last2 

Compare two ranges lexicographically.

This message simply sends the message lexicographicalCompareFrom:to:andFrom:andTo:predicate: using OLLess as the predicate.

Parameters:
first1the first in the first range of elements to test
last1one position beyond the last in the first range of elements to test
first2the first in the second range of elements to test
last2one 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
+ (BOOL) lexicographicalCompareFrom: (OLForwardIterator *)  first1
to: (OLForwardIterator *)  last1
andFrom: (OLForwardIterator *)  first2
andTo: (OLForwardIterator *)  last2
predicate: (id< OLBoolBinaryFunction >)  pred 

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:
first1the first in the first range of elements to test
last1one position beyond the last in the first range of elements to test
first2the first in the second range of elements to test
last2one position beyond the last in the second range of elements to test
predthe 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:
leftthe first element to compare
rightthe second element to compare
Returns:
the element that is the maximum element according to OLLess
+ (id) max: (id)  left
or: (id)  right
predicate: (id< OLBoolBinaryFunction >)  pred 

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:
leftthe first element to compare
rightthe second element to compare
predthe 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:
leftthe first element to compare
rightthe second element to compare
Returns:
the element that is the minimum element according to OLLess
+ (id) min: (id)  left
or: (id)  right
predicate: (id< OLBoolBinaryFunction >)  pred 

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:
leftthe first element to compare
rightthe second element to compare
predthe predicate that is used to compare the two objects
Returns:
the element that is the minimum element according to pred

ObjectiveLibGenerated Sat Feb 15 2014 07:45:33, © 2004-2007 Will Mason