All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class COM.objectspace.jgl.algorithms.Comparing

java.lang.Object
   |
   +----COM.objectspace.jgl.algorithms.Comparing

public final class Comparing
extends Object
The Comparing class contains generic comparison algorithms.

See Also:
ComparingExamples

Method Index

 o equal(Container, Container)
Scan two containers and return true if the containers are the same size and every element in one container matches its counterpart using equals().
 o equal(InputIterator, InputIterator, InputIterator)
Scan two sequences of the same size and return true if every element in one sequence matches its counterpart using equals().
 o lexicographicalCompare(Container, Container)
Return true if one container is lexicographically less than another.
 o lexicographicalCompare(Container, Container, BinaryPredicate)
Return true if one container is lexicographically less than another.
 o lexicographicalCompare(InputIterator, InputIterator, InputIterator, InputIterator)
Return true if one sequence is lexicographically less than another.
 o lexicographicalCompare(InputIterator, InputIterator, InputIterator, InputIterator, BinaryPredicate)
Return true if one sequence is lexicographically less than another.
 o median(Object, Object, Object, BinaryPredicate)
Return the median value of three objects, using a comparator to perform the comparisons.
 o mismatch(Container, Container)
Scan two containers and return a pair of iterators that are positioned at the first mismatched elements.
 o mismatch(Container, Container, BinaryPredicate)
Scan two containers and return a pair of iterators that are positioned at the first mismatched elements.
 o mismatch(InputIterator, InputIterator, InputIterator)
Scan two sequences and return a pair of iterators that are positioned at the first mismatched elements.
 o mismatch(InputIterator, InputIterator, InputIterator, BinaryPredicate)
Scan two sequences and return a pair of iterators that are positioned at the first mismatched elements.

Methods

 o median
 public static Object median(Object a,
                             Object b,
                             Object c,
                             BinaryPredicate comparator)
Return the median value of three objects, using a comparator to perform the comparisons.

Parameters:
a - The first object.
b - The second object.
c - The third object.
comparator - The comparator object.
Returns:
The median value.
 o mismatch
 public static Pair mismatch(InputIterator first1,
                             InputIterator last1,
                             InputIterator first2)
Scan two sequences and return a pair of iterators that are positioned at the first mismatched elements. Use equals() to perform the comparison. If the first iterator reaches past the end of the first sequence, stop the scan and return the iterator's values at that point. Time complexity is linear and space complexity is constant.

Parameters:
first1 - An iterator positioned at the first element of the first sequence.
last1 - An iterator positioned immediately after the last element of the first sequence.
first2 - An iterator positioned at the first element of the second sequence.
Returns:
A pair of iterators positioned at the first mismatched elements.
Throws: IllegalArgumentException
If the iterators are incompatible.
 o mismatch
 public static Pair mismatch(Container container1,
                             Container container2)
Scan two containers and return a pair of iterators that are positioned at the first mismatched elements. Use equals() to perform the comparison. If the first iterator reaches past the end of the first container, stop the scan and return the iterator's values at that point. Time complexity is linear and space complexity is constant.

Parameters:
container1 - The first container.
container2 - The second container.
Returns:
A pair of iterators positioned at the first mismatched elements.
 o mismatch
 public static Pair mismatch(InputIterator first1,
                             InputIterator last1,
                             InputIterator first2,
                             BinaryPredicate predicate)
Scan two sequences and return a pair of iterators that are positioned at the first mismatched elements. Use the specified predicate to perform the comparison. If the first iterator reaches past the end of the first sequence, stop the scan and return the iterator's values at that point. Time complexity is linear and space complexity is constant.

Parameters:
first1 - An iterator positioned at the first element of the first sequence.
last1 - An iterator positioned immediately after the last element of the first sequence.
first2 - An iterator positioned at the first element of the second sequence.
predicate - A binary function.
Returns:
A pair of iterators positioned at the first mismatched elements.
Throws: IllegalArgumentException
If the iterators are incompatible.
 o mismatch
 public static Pair mismatch(Container container1,
                             Container container2,
                             BinaryPredicate predicate)
Scan two containers and return a pair of iterators that are positioned at the first mismatched elements. Use the specified predicate to perform the comparison. If the first iterator reaches past the end of the first container, stop the scan and return the iterator's values at that point. Time complexity is linear and space complexity is constant.

Parameters:
container1 - The first container.
container2 - The second container.
predicate - A binary predicate.
Returns:
A pair of iterators positioned at the first mismatched elements.
 o equal
 public static boolean equal(InputIterator first1,
                             InputIterator last1,
                             InputIterator first2)
Scan two sequences of the same size and return true if every element in one sequence matches its counterpart using equals(). The time complexity is linear and the space complexity is constant.

Parameters:
first1 - An iterator positioned at the first element of the first sequence.
last1 - An iterator positioned immediately after the last element of the first sequence.
first2 - An iterator positioned at the first element of the second sequence.
Returns:
true if the sequences match.
Throws: IllegalArgumentException
If the iterators are incompatible.
 o equal
 public static boolean equal(Container container1,
                             Container container2)
Scan two containers and return true if the containers are the same size and every element in one container matches its counterpart using equals(). The time complexity is linear and the space complexity is constant.

Parameters:
container1 - The first container.
container2 - The second container.
Returns:
true if the containers match.
 o lexicographicalCompare
 public static boolean lexicographicalCompare(InputIterator first1,
                                              InputIterator last1,
                                              InputIterator first2,
                                              InputIterator last2)
Return true if one sequence is lexicographically less than another. Comapre hashCode() values to determine ordering. The time complexity is linear and the space complexity is constant.

Parameters:
first1 - An iterator positioned at the first element of the first sequence.
last1 - An iterator positioned immediately after the last element of the first sequence.
first2 - An iterator positioned at the first element of the second sequence.
last2 - An iterator positioned immediately after the last element of the second sequence.
Returns:
true if the first sequence is lexicographically less than the second.
Throws: IllegalArgumentException
If the iterators are incompatible.
 o lexicographicalCompare
 public static boolean lexicographicalCompare(Container container1,
                                              Container container2)
Return true if one container is lexicographically less than another. Comapre hashCode() values to determine ordering. The time complexity is linear and the space complexity is constant.

Parameters:
container1 - The first container.
container2 - The second container.
Returns:
true if the first container is lexicographically less than the second.
Throws: IllegalArgumentException
If the iterators are incompatible.
 o lexicographicalCompare
 public static boolean lexicographicalCompare(InputIterator first1,
                                              InputIterator last1,
                                              InputIterator first2,
                                              InputIterator last2,
                                              BinaryPredicate comparator)
Return true if one sequence is lexicographically less than another. Use a specified comparator to compare corresponding elements. The time complexity is linear and the space complexity is constant.

Parameters:
first1 - An iterator positioned at the first element of the first sequence.
last1 - An iterator positioned immediately after the last element of the first sequence.
first2 - An iterator positioned at the first element of the second sequence.
last2 - An iterator positioned immediately after the last element of the second sequence.
comparator - A binary predicate that returns true if its first operand is "less" than its second operand.
Returns:
true if the first sequence is lexicographically less than the second.
Throws: IllegalArgumentException
If the iterators are incompatible.
 o lexicographicalCompare
 public static boolean lexicographicalCompare(Container container1,
                                              Container container2,
                                              BinaryPredicate comparator)
Return true if one container is lexicographically less than another. Use a specified comparator to compare corresponding elements. The time complexity is linear and the space complexity is constant.

Parameters:
container1 - The first container.
container2 - The second container.
comparator - A binary predicate that returns true if its first operand is "less" than its second operand.
Returns:
true if the first container is lexicographically less than the second.

All Packages  Class Hierarchy  This Package  Previous  Next  Index