package com.google.common.collect; import com.google.common.base.Preconditions; import java.util.Comparator; import java.util.Iterator; /* loaded from: classes2.dex */ public final class Comparators { private Comparators() { } public static Comparator> lexicographical(Comparator comparator) { return new LexicographicalOrdering((Comparator) Preconditions.checkNotNull(comparator)); } public static boolean isInOrder(Iterable iterable, Comparator comparator) { Preconditions.checkNotNull(comparator); Iterator it = iterable.iterator(); if (!it.hasNext()) { return true; } T next = it.next(); while (it.hasNext()) { T next2 = it.next(); if (comparator.compare(next, next2) > 0) { return false; } next = next2; } return true; } public static boolean isInStrictOrder(Iterable iterable, Comparator comparator) { Preconditions.checkNotNull(comparator); Iterator it = iterable.iterator(); if (!it.hasNext()) { return true; } T next = it.next(); while (it.hasNext()) { T next2 = it.next(); if (comparator.compare(next, next2) >= 0) { return false; } next = next2; } return true; } public static > T min(T t, T t2) { return t.compareTo(t2) > 0 ? t2 : t; } public static T min(T t, T t2, Comparator comparator) { return comparator.compare(t, t2) > 0 ? t2 : t; } public static > T max(T t, T t2) { return t.compareTo(t2) < 0 ? t2 : t; } public static T max(T t, T t2, Comparator comparator) { return comparator.compare(t, t2) < 0 ? t2 : t; } }