|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.common.collect.Ordering<T>
public abstract class Ordering<T>
A base class for Serializable comparators that
provides convenience methods for common uses.
| Constructor Summary | |
|---|---|
Ordering()
|
|
| Method Summary | ||
|---|---|---|
int |
binarySearch(java.util.List<? extends T> sortedList,
T key)
Searches
list for key using the binary search algorithm. |
|
static
|
forComparator(java.util.Comparator<T> comparator)
Returns an Ordering for comparator. |
|
|
max(E a,
E b)
Returns the larger of the two values according to this ordering. |
|
|
max(E a,
E b,
E c,
E... rest)
Returns the largest of the specified values according to this ordering. |
|
|
max(java.lang.Iterable<E> iterable)
Returns the largest of the specified values according to this ordering. |
|
|
min(E a,
E b)
Returns the smaller of the two values according to this ordering. |
|
|
min(E a,
E b,
E c,
E... rest)
Returns the smallest of the specified values according to this ordering. |
|
|
min(java.lang.Iterable<E> iterable)
Returns the smallest of the specified values according to this ordering. |
|
Ordering<T> |
reverseOrder()
Returns the ordering that is the reverse of this ordering. |
|
void |
sort(java.util.List<? extends T> list)
Sorts list according
to this ordering. |
|
|
sortedCopy(java.lang.Iterable<E> iterable)
Returns a copy of the given iterable sorted by this ordering. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Comparator |
|---|
compare, equals |
| Constructor Detail |
|---|
public Ordering()
| Method Detail |
|---|
public static <T> Ordering<T> forComparator(java.util.Comparator<T> comparator)
comparator.
comparator - the comparator that defines the orderpublic Ordering<T> reverseOrder()
reverse of this ordering.
public int binarySearch(java.util.List<? extends T> sortedList,
T key)
Searches
list for key using the binary search algorithm. The list
must be sorted using this ordering.
sortedList - the list to be searchedkey - the key to be searched forpublic void sort(java.util.List<? extends T> list)
Sorts list according
to this ordering.
list - the list to be sortedpublic <E extends T> java.util.List<E> sortedCopy(java.lang.Iterable<E> iterable)
Unlike Sets.newTreeSet(Comparator, Iterable), this method does
not collapse elements that compare as zero, and the resulting collection
does not maintain its own sort order. If you have no preference on these
issues, these two alternatives are equivalent, so you can choose for
performance factors.
iterable - the elements to be copied and sorted
public <E extends T> E max(java.lang.Iterable<E> iterable)
iterable - the iterable whose maximum element is to be determined
java.util.NoSuchElementException - if iterable is empty
java.lang.ClassCastException - if the parameters are not mutually
comparable under this ordering.
public <E extends T> E max(E a,
E b,
E c,
E... rest)
a - value to compare, returned if greater than or equal to the rest.b - value to comparec - value to comparerest - values to compare
java.lang.ClassCastException - if the parameters are not mutually
comparable under this ordering.
public <E extends T> E max(E a,
E b)
a - value to compare, returned if greater than or equal to b.b - value to compare.
java.lang.ClassCastException - if the parameters are not mutually
comparable under this ordering.public <E extends T> E min(java.lang.Iterable<E> iterable)
iterable - the iterable whose minimum element is to be determined
java.util.NoSuchElementException - if iterable is empty
java.lang.ClassCastException - if the parameters are not mutually
comparable under this ordering.
public <E extends T> E min(E a,
E b,
E c,
E... rest)
a - value to compare, returned if less than or equal to the rest.b - value to comparec - value to comparerest - values to compare
java.lang.ClassCastException - if the parameters are not mutually
comparable under this ordering.
public <E extends T> E min(E a,
E b)
a - value to compare, returned if less than or equal to b.b - value to compare.
java.lang.ClassCastException - if the parameters are not mutually
comparable under this ordering.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||