Class AllEqualOrdering
- java.lang.Object
-
- com.google.common.collect.Ordering<java.lang.Object>
-
- com.google.common.collect.AllEqualOrdering
-
- All Implemented Interfaces:
java.io.Serializable
,java.util.Comparator<java.lang.Object>
final class AllEqualOrdering extends Ordering<java.lang.Object> implements java.io.Serializable
An ordering that treats all references as equals, even nulls.
-
-
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) static AllEqualOrdering
INSTANCE
private static long
serialVersionUID
-
Fields inherited from class com.google.common.collect.Ordering
LEFT_IS_GREATER, RIGHT_IS_GREATER
-
-
Constructor Summary
Constructors Constructor Description AllEqualOrdering()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(java.lang.Object left, java.lang.Object right)
<E> ImmutableList<E>
immutableSortedCopy(java.lang.Iterable<E> iterable)
Returns an immutable list containingelements
sorted by this ordering.private java.lang.Object
readResolve()
<S> Ordering<S>
reverse()
Returns the reverse of this ordering; theOrdering
equivalent toCollections.reverseOrder(Comparator)
.<E> java.util.List<E>
sortedCopy(java.lang.Iterable<E> iterable)
Returns a mutable list containingelements
sorted by this ordering; use this only when the resulting list may need further modification, or may containnull
.java.lang.String
toString()
-
Methods inherited from class com.google.common.collect.Ordering
allEqual, arbitrary, binarySearch, compound, compound, explicit, explicit, from, from, greatestOf, greatestOf, isOrdered, isStrictlyOrdered, leastOf, leastOf, lexicographical, max, max, max, max, min, min, min, min, natural, nullsFirst, nullsLast, onKeys, onResultOf, usingToString
-
-
-
-
Field Detail
-
INSTANCE
static final AllEqualOrdering INSTANCE
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Method Detail
-
compare
public int compare(@CheckForNull java.lang.Object left, @CheckForNull java.lang.Object right)
-
sortedCopy
public <E> java.util.List<E> sortedCopy(java.lang.Iterable<E> iterable)
Description copied from class:Ordering
Returns a mutable list containingelements
sorted by this ordering; use this only when the resulting list may need further modification, or may containnull
. The input is not modified. The returned list is serializable and has random access.Unlike
Sets.newTreeSet(Iterable)
, this method does not discard elements that are duplicates according to the comparator. The sort performed is stable, meaning that such elements will appear in the returned list in the same order they appeared inelements
.Performance note: According to our benchmarking on Open JDK 7,
Ordering.immutableSortedCopy(java.lang.Iterable<E>)
generally performs better (in both time and space) than this method, and this method in turn generally performs better than copying the list and callingCollections.sort(List)
.- Overrides:
sortedCopy
in classOrdering<java.lang.Object>
-
immutableSortedCopy
public <E> ImmutableList<E> immutableSortedCopy(java.lang.Iterable<E> iterable)
Description copied from class:Ordering
Returns an immutable list containingelements
sorted by this ordering. The input is not modified.Unlike
Sets.newTreeSet(Iterable)
, this method does not discard elements that are duplicates according to the comparator. The sort performed is stable, meaning that such elements will appear in the returned list in the same order they appeared inelements
.Performance note: According to our benchmarking on Open JDK 7, this method is the most efficient way to make a sorted copy of a collection.
- Overrides:
immutableSortedCopy
in classOrdering<java.lang.Object>
-
reverse
public <S> Ordering<S> reverse()
Description copied from class:Ordering
Returns the reverse of this ordering; theOrdering
equivalent toCollections.reverseOrder(Comparator)
.Java 8 users: Use
thisComparator.reversed()
instead.
-
readResolve
private java.lang.Object readResolve()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-