what-the-bank/sources/com/google/common/collect/LexicographicalOrdering.java

56 lines
1.8 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.common.collect;
import java.io.Serializable;
import java.util.Comparator;
import java.util.Iterator;
/* loaded from: classes2.dex */
final class LexicographicalOrdering<T> extends Ordering<Iterable<T>> implements Serializable {
private static final long serialVersionUID = 0;
final Comparator<? super T> elementOrder;
/* JADX INFO: Access modifiers changed from: package-private */
public LexicographicalOrdering(Comparator<? super T> comparator) {
this.elementOrder = comparator;
}
@Override // com.google.common.collect.Ordering, java.util.Comparator
public final int compare(Iterable<T> iterable, Iterable<T> iterable2) {
Iterator<T> it = iterable.iterator();
Iterator<T> it2 = iterable2.iterator();
while (it.hasNext()) {
if (!it2.hasNext()) {
return 1;
}
int compare = this.elementOrder.compare(it.next(), it2.next());
if (compare != 0) {
return compare;
}
}
return it2.hasNext() ? -1 : 0;
}
@Override // java.util.Comparator
public final boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof LexicographicalOrdering) {
return this.elementOrder.equals(((LexicographicalOrdering) obj).elementOrder);
}
return false;
}
public final int hashCode() {
return this.elementOrder.hashCode() ^ 2075626741;
}
public final String toString() {
String valueOf = String.valueOf(this.elementOrder);
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 18);
sb.append(valueOf);
sb.append(".lexicographical()");
return sb.toString();
}
}