Class ReverseOrdering<T>
- java.lang.Object
-
- com.google.common.collect.Ordering<T>
-
- com.google.common.collect.ReverseOrdering<T>
-
- All Implemented Interfaces:
java.io.Serializable,java.util.Comparator<T>
@GwtCompatible(serializable=true) final class ReverseOrdering<T> extends Ordering<T> implements java.io.Serializable
An ordering that uses the reverse of a given order.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.collect.Ordering
Ordering.ArbitraryOrdering, Ordering.IncomparableValueException
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Ordering<? super T>forwardOrderprivate static longserialVersionUID-
Fields inherited from class com.google.common.collect.Ordering
LEFT_IS_GREATER, RIGHT_IS_GREATER
-
-
Constructor Summary
Constructors Constructor Description ReverseOrdering(Ordering<? super T> forwardOrder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompare(T a, T b)booleanequals(java.lang.Object object)inthashCode()<E extends T>
Emax(E a, E b)Returns the greater of the two values according to this ordering.<E extends T>
Emax(E a, E b, E c, E... rest)Returns the greatest of the specified values according to this ordering.<E extends T>
Emax(java.lang.Iterable<E> iterable)Returns the greatest of the specified values according to this ordering.<E extends T>
Emax(java.util.Iterator<E> iterator)Returns the greatest of the specified values according to this ordering.<E extends T>
Emin(E a, E b)Returns the lesser of the two values according to this ordering.<E extends T>
Emin(E a, E b, E c, E... rest)Returns the least of the specified values according to this ordering.<E extends T>
Emin(java.lang.Iterable<E> iterable)Returns the least of the specified values according to this ordering.<E extends T>
Emin(java.util.Iterator<E> iterator)Returns the least of the specified values according to this ordering.<S extends T>
Ordering<S>reverse()Returns the reverse of this ordering; theOrderingequivalent toCollections.reverseOrder(Comparator).java.lang.StringtoString()-
Methods inherited from class com.google.common.collect.Ordering
allEqual, arbitrary, binarySearch, compound, compound, explicit, explicit, from, from, greatestOf, greatestOf, immutableSortedCopy, isOrdered, isStrictlyOrdered, leastOf, leastOf, lexicographical, natural, nullsFirst, nullsLast, onKeys, onResultOf, sortedCopy, usingToString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Method Detail
-
reverse
public <S extends T> Ordering<S> reverse()
Description copied from class:OrderingReturns the reverse of this ordering; theOrderingequivalent toCollections.reverseOrder(Comparator).Java 8 users: Use
thisComparator.reversed()instead.
-
min
public <E extends T> E min(E a, E b)
Description copied from class:OrderingReturns the lesser of the two values according to this ordering. If the values compare as 0, the first is returned.Implementation note: this method is invoked by the default implementations of the other
minoverloads, so overriding it will affect their behavior.Java 8 users: Use
Collections.min(Arrays.asList(a, b), thisComparator)instead (but note that it does not guarantee which tied minimum element is returned).
-
min
public <E extends T> E min(E a, E b, E c, E... rest)
Description copied from class:OrderingReturns the least of the specified values according to this ordering. If there are multiple least values, the first of those is returned.Java 8 users: Use
Collections.min(Arrays.asList(a, b, c...), thisComparator)instead (but note that it does not guarantee which tied minimum element is returned).
-
min
public <E extends T> E min(java.util.Iterator<E> iterator)
Description copied from class:OrderingReturns the least of the specified values according to this ordering. If there are multiple least values, the first of those is returned. The iterator will be left exhausted: itshasNext()method will returnfalse.Java 8 users: Use
Streams.stream(iterator).min(thisComparator).get()instead (but note that it does not guarantee which tied minimum element is returned).
-
min
public <E extends T> E min(java.lang.Iterable<E> iterable)
Description copied from class:OrderingReturns the least of the specified values according to this ordering. If there are multiple least values, the first of those is returned.Java 8 users: If
iterableis aCollection, useCollections.min(collection, thisComparator)instead. Otherwise, useStreams.stream(iterable).min(thisComparator).get()instead. Note that these alternatives do not guarantee which tied minimum element is returned)
-
max
public <E extends T> E max(E a, E b)
Description copied from class:OrderingReturns the greater of the two values according to this ordering. If the values compare as 0, the first is returned.Implementation note: this method is invoked by the default implementations of the other
maxoverloads, so overriding it will affect their behavior.Java 8 users: Use
Collections.max(Arrays.asList(a, b), thisComparator)instead (but note that it does not guarantee which tied maximum element is returned).
-
max
public <E extends T> E max(E a, E b, E c, E... rest)
Description copied from class:OrderingReturns the greatest of the specified values according to this ordering. If there are multiple greatest values, the first of those is returned.Java 8 users: Use
Collections.max(Arrays.asList(a, b, c...), thisComparator)instead (but note that it does not guarantee which tied maximum element is returned).
-
max
public <E extends T> E max(java.util.Iterator<E> iterator)
Description copied from class:OrderingReturns the greatest of the specified values according to this ordering. If there are multiple greatest values, the first of those is returned. The iterator will be left exhausted: itshasNext()method will returnfalse.Java 8 users: Use
Streams.stream(iterator).max(thisComparator).get()instead (but note that it does not guarantee which tied maximum element is returned).
-
max
public <E extends T> E max(java.lang.Iterable<E> iterable)
Description copied from class:OrderingReturns the greatest of the specified values according to this ordering. If there are multiple greatest values, the first of those is returned.Java 8 users: If
iterableis aCollection, useCollections.max(collection, thisComparator)instead. Otherwise, useStreams.stream(iterable).max(thisComparator).get()instead. Note that these alternatives do not guarantee which tied maximum element is returned)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object object)
- Specified by:
equalsin interfacejava.util.Comparator<T>- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-