public class CompareArrayElements extends Object implements SortInts
Constructor and Description |
---|
CompareArrayElements(Object[] items,
Comparer comparer)
Creates a new CompareArrayElements which uses the specified Comparer to
compare objects in the specified array.
|
CompareArrayElements(Object[] items,
Sorter sorter,
boolean descending)
Creates a new CompareArrayElements which uses the specified Comparer to
compare objects in the specified array.
|
Modifier and Type | Method and Description |
---|---|
int |
compare(int one,
int two)
Compare the two integer values provided by treating them as indexes
into the array and then using the Comparer to compare the Objects
found at those indexes.
|
int |
sortInts(int one,
int two,
boolean descending)
This should return <0 if one is considered less than two, >0 if one is
considered more than two, and 0 if they are considered equal.
|
public CompareArrayElements(Object[] items, Comparer comparer)
items
- the items to compare.comparer
- a Comparer to compare the objects in the array. If this is null
then it is assumed that the objects implement the Comparable interface.public CompareArrayElements(Object[] items, Sorter sorter, boolean descending)
items
- the items to compare.sorter
- a Sorter to compare the objects in the array. If this is null
then it is assumed that the objects implement the Comparable interface.public int compare(int one, int two)
compare
in interface CompareInts