mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-28 18:12:31 -06:00
3513 lines
210 KiB
Java
3513 lines
210 KiB
Java
|
package kotlin.collections;
|
||
|
|
||
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||
|
import androidx.exifinterface.media.ExifInterface;
|
||
|
import androidx.media3.exoplayer.upstream.CmcdHeadersFactory;
|
||
|
import defpackage.DeviceControl$Companion$$ExternalSyntheticLambda4;
|
||
|
import io.sentry.protocol.MetricSummary;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Collection;
|
||
|
import java.util.Comparator;
|
||
|
import java.util.HashSet;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.LinkedHashMap;
|
||
|
import java.util.LinkedHashSet;
|
||
|
import java.util.List;
|
||
|
import java.util.ListIterator;
|
||
|
import java.util.Map;
|
||
|
import java.util.NoSuchElementException;
|
||
|
import java.util.RandomAccess;
|
||
|
import java.util.Set;
|
||
|
import kotlin.Deprecated;
|
||
|
import kotlin.DeprecatedSinceKotlin;
|
||
|
import kotlin.Metadata;
|
||
|
import kotlin.Pair;
|
||
|
import kotlin.ReplaceWith;
|
||
|
import kotlin.TuplesKt;
|
||
|
import kotlin.UInt;
|
||
|
import kotlin.ULong;
|
||
|
import kotlin.Unit;
|
||
|
import kotlin.comparisons.ComparisonsKt;
|
||
|
import kotlin.comparisons.ComparisonsKt__ComparisonsKt$compareBy$2;
|
||
|
import kotlin.comparisons.ComparisonsKt__ComparisonsKt$compareByDescending$1;
|
||
|
import kotlin.internal.PlatformImplementationsKt;
|
||
|
import kotlin.jvm.functions.Function0;
|
||
|
import kotlin.jvm.functions.Function1;
|
||
|
import kotlin.jvm.functions.Function2;
|
||
|
import kotlin.jvm.functions.Function3;
|
||
|
import kotlin.jvm.internal.Intrinsics;
|
||
|
import kotlin.random.Random;
|
||
|
import kotlin.ranges.IntRange;
|
||
|
import kotlin.ranges.RangesKt;
|
||
|
import kotlin.sequences.Sequence;
|
||
|
import kotlin.sequences.SequencesKt;
|
||
|
import kotlin.text.StringsKt;
|
||
|
import tech.rabbit.r1launcher.BuildConfig;
|
||
|
|
||
|
/* compiled from: _Collections.kt */
|
||
|
@Metadata(d1 = {"\u0000ê\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u001c\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010$\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010%\n\u0002\b\b\n\u0002\u0010\u0006\n\u0002\u0010\u0005\n\u0002\b\u0002\n\u0002\u0010\u0007\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\t\n\u0000\n\u0002\u0010\n\n\u0002\b\u0002\n\u0002\u0010 \n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u001e\n\u0002\b\u0013\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u001f\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0000\n\u0002\b\u001d\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\u0002\n\u0002\b\u0006\n\u0002\u0010!\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\"\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\r\n\u0002\b\u0006\n\u0002\u0010\u000e\n\u0002\b\f\n\u0002\u0010\u000f\n\u0002\b\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0019\n\u0002\u0010\u0011\n\u0002\b\u000e\n\u0002\u0018\u0002\n\u0002\b\u001e\n\u0002\u0018\u0002\n\u0002\b\u0013\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0010\u0018\n\u0000\n\u0002\u0010\u0012\n\u0000\n\u0002\u0010\u0019\n\u0002\u0010\f\n\u0002\b\u0002\n\u0002\u0010\u0013\n\u0000\n\u0002\u0010\u0014\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0015\n\u0002\b\u0002\n\u0002\u0010\u0016\n\u0002\b\u0002\n\u0002\u0010#\n\u0002\b\u0002\n\u0002\u0010\u0017\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0006\u001a0\u0010\u0000\u001a\u00020\u0001\"\u0004\b\u0000\u0010\u0002*\b\u0012\u0004\u0012\u0002H\u00020\u00032\u0012\u0010\u0004\u001a\u000e\u0012\u0004\u0012\u0002H\u0002\u0012\u0004\u0012\u00020\u00010\u0005H\u0086\bø\u0001\u0000\u001a\u0016\u0010\u0006\u001a\u00020\u0001\"\u0004\b\u0000\u0010\u0002*\b\u0012\u0004\u0012\u0002H\u00020\u0003\u001a0\u0010\u0006\u001a\u00020\u0001\"\u0004\b\u0000\u0010\u0002*\b\u0012\u0004\u0012\u0002H\u00020\u00032\u0012\u0010\u0004\u001a\u000e\u0012\u0004\u0012\u0002H\u0002\u0012\u0004\u0012\u00020\u00010\u0005H\u0086\bø\u0001\u0000\u001a\u001f\u0010\u0007\u001a\b\u0012\u0004\u0012\u0002H\u00020\u0003\"\u0004\b\u0000\u0010\u0002*\b\u0012\u0004\u0012\u0002H\u00020\u0003H\u0087\b\u001a\u001c\u0010\b\u001a\b\u0012\u0004\u0012\u0002H\u00020\t\"\u0004\b\u0000\u0010\u0002*\b\u0012\u0004\u0012\u0002H\u00020\u0003\u001aT\u0010\n\u001a\u000e\u0012\u0004\u0012\u0002H\f\u0012\u0004\u0012\u0002H\r0\u000b\"\u0004\b\u0000\u0010\u0002\"\u0004\b\u0001\u0010\f\"\u0004\b\u0002\u0010\r*\b\u0012\u0004\u0012\u0002H\u00020\u00032\u001e\u0010\u000e\u001a\u001a\u0012\u0004\u0012\u0002H\u0002\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u0002H\f\u0012\u0004\u0012\u0002H\r0\u000f0\u0005H\u0086\bø\u0001\u0000\u001aB\u0010\u0010\u001a\u000e\u0012\u0004\u0012\u0002H\f\u0012\u0004\u0012\u0002H\u00020\u000b\"\u0004\b\u0000\u0010\u0002\"\u0004\b\u0001\u0010\f*\b\u0012\u0004\u0012\u0002H\u00020\u00032\u0012\u0010\u0011\u001a\u000e\u0012\u0004\u0012\u0002H\u0002\u0012\u0004\u0012\u0002H\f0\u0005H\u0086\bø\u0001\u0000\u001a\\\u0010\u0010\u001a\u000e\u0012\u0004\u0012\u0002H\f\u0012\u0004\u0012\u0002H\r0\u000b\"\u0004\b\u0000\u0010\u0002\"\u0004\b\u0001\u0010\f\"\u0004\b\u0002\u0010\r*\b\u0012\u0004\u0012\u0002H\u00020\u00032\u0012\u0010\u0011\u001a\u000e\u0012\u0004\u0012\u0002H\u0002\u0012\u0004\u0012\u0002H\f0\u00052\u0012\u0010\u0012\u001a\u000e\u0012\u0004\u0012\u0002H\u0002\u0012\u0004\u0012\u0002H\r0\u0005H\u0086\bø\u0001\u0000\u001a]\u0010\u0013\u001a\u0002H\u0014\"\u0004\b\u0000\u0010\u0002\"\u0004\b\u0001\u0010\f\"\u0018\b\u0002\u0010\u0014*\u0012\u0012\u0006\b\u0000\u0012\u0002H\f\u0012\u0006\b\u0000\u0012\u0002H\u00020\u0015*\b\u0012\u0004\u0012\u0002H\u00020\u00032\u0006\u0010\u0016\u001a\u0002H\u00142\u0012\u0010\u0011\u001a\u000e\u0012\u0004\u0012\u0002H\u0002\u0012\u0004\u0012\u0002H\f0\u0005H\u0086\bø\u0001\u0000¢\u0006\u0002\u0010\u0017\u001aw\u0010\u0013\u001a\u0002H\u0014\"\u0004\b\u0000\u0010\u0002\"\u0004\b\u000
|
||
|
/* loaded from: classes3.dex */
|
||
|
public class CollectionsKt___CollectionsKt extends CollectionsKt___CollectionsJvmKt {
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
private static final <T> Iterable<T> asIterable(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
return iterable;
|
||
|
}
|
||
|
|
||
|
private static final <T> T component1(List<? extends T> list) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
return list.get(0);
|
||
|
}
|
||
|
|
||
|
private static final <T> T component2(List<? extends T> list) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
return list.get(1);
|
||
|
}
|
||
|
|
||
|
private static final <T> T component3(List<? extends T> list) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
return list.get(2);
|
||
|
}
|
||
|
|
||
|
private static final <T> T component4(List<? extends T> list) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
return list.get(3);
|
||
|
}
|
||
|
|
||
|
private static final <T> T component5(List<? extends T> list) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
return list.get(4);
|
||
|
}
|
||
|
|
||
|
public static final <T> boolean contains(Iterable<? extends T> iterable, T t) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (iterable instanceof Collection) {
|
||
|
return ((Collection) iterable).contains(t);
|
||
|
}
|
||
|
return CollectionsKt.indexOf(iterable, t) >= 0;
|
||
|
}
|
||
|
|
||
|
public static final <T> T elementAt(Iterable<? extends T> iterable, final int i) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (iterable instanceof List) {
|
||
|
return (T) ((List) iterable).get(i);
|
||
|
}
|
||
|
return (T) CollectionsKt.elementAtOrElse(iterable, i, new Function1<Integer, T>() { // from class: kotlin.collections.CollectionsKt___CollectionsKt$elementAt$1
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
||
|
{
|
||
|
super(1);
|
||
|
}
|
||
|
|
||
|
public final T invoke(int i2) {
|
||
|
throw new IndexOutOfBoundsException("Collection doesn't contain element at index " + i + '.');
|
||
|
}
|
||
|
|
||
|
@Override // kotlin.jvm.functions.Function1
|
||
|
public /* bridge */ /* synthetic */ Object invoke(Integer num) {
|
||
|
return invoke(num.intValue());
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
private static final <T> T elementAt(List<? extends T> list, int i) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
return list.get(i);
|
||
|
}
|
||
|
|
||
|
public static final <T> T elementAtOrElse(Iterable<? extends T> iterable, int i, Function1<? super Integer, ? extends T> defaultValue) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(defaultValue, "defaultValue");
|
||
|
if (iterable instanceof List) {
|
||
|
List list = (List) iterable;
|
||
|
return (i < 0 || i > CollectionsKt.getLastIndex(list)) ? defaultValue.invoke(Integer.valueOf(i)) : (T) list.get(i);
|
||
|
}
|
||
|
if (i < 0) {
|
||
|
return defaultValue.invoke(Integer.valueOf(i));
|
||
|
}
|
||
|
int i2 = 0;
|
||
|
for (T t : iterable) {
|
||
|
int i3 = i2 + 1;
|
||
|
if (i == i2) {
|
||
|
return t;
|
||
|
}
|
||
|
i2 = i3;
|
||
|
}
|
||
|
return defaultValue.invoke(Integer.valueOf(i));
|
||
|
}
|
||
|
|
||
|
private static final <T> T elementAtOrElse(List<? extends T> list, int i, Function1<? super Integer, ? extends T> defaultValue) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(defaultValue, "defaultValue");
|
||
|
return (i < 0 || i > CollectionsKt.getLastIndex(list)) ? defaultValue.invoke(Integer.valueOf(i)) : list.get(i);
|
||
|
}
|
||
|
|
||
|
public static final <T> T elementAtOrNull(Iterable<? extends T> iterable, int i) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (iterable instanceof List) {
|
||
|
return (T) CollectionsKt.getOrNull((List) iterable, i);
|
||
|
}
|
||
|
if (i < 0) {
|
||
|
return null;
|
||
|
}
|
||
|
int i2 = 0;
|
||
|
for (T t : iterable) {
|
||
|
int i3 = i2 + 1;
|
||
|
if (i == i2) {
|
||
|
return t;
|
||
|
}
|
||
|
i2 = i3;
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
private static final <T> T elementAtOrNull(List<? extends T> list, int i) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
return (T) CollectionsKt.getOrNull(list, i);
|
||
|
}
|
||
|
|
||
|
public static final <T> T first(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (iterable instanceof List) {
|
||
|
return (T) CollectionsKt.first((List) iterable);
|
||
|
}
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException("Collection is empty.");
|
||
|
}
|
||
|
return it.next();
|
||
|
}
|
||
|
|
||
|
public static final <T> T first(List<? extends T> list) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
if (list.isEmpty()) {
|
||
|
throw new NoSuchElementException("List is empty.");
|
||
|
}
|
||
|
return list.get(0);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Type inference failed for: r0v3, types: [T, java.lang.Object] */
|
||
|
public static final <T> T first(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
for (T t : iterable) {
|
||
|
if (predicate.invoke(t).booleanValue()) {
|
||
|
return t;
|
||
|
}
|
||
|
}
|
||
|
throw new NoSuchElementException("Collection contains no element matching the predicate.");
|
||
|
}
|
||
|
|
||
|
private static final <T, R> R firstNotNullOf(Iterable<? extends T> iterable, Function1<? super T, ? extends R> transform) {
|
||
|
R r;
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (true) {
|
||
|
if (!it.hasNext()) {
|
||
|
r = null;
|
||
|
break;
|
||
|
}
|
||
|
r = transform.invoke(it.next());
|
||
|
if (r != null) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if (r != null) {
|
||
|
return r;
|
||
|
}
|
||
|
throw new NoSuchElementException("No element of the collection was transformed to a non-null value.");
|
||
|
}
|
||
|
|
||
|
private static final <T, R> R firstNotNullOfOrNull(Iterable<? extends T> iterable, Function1<? super T, ? extends R> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
R invoke = transform.invoke(it.next());
|
||
|
if (invoke != null) {
|
||
|
return invoke;
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
public static final <T> T firstOrNull(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (iterable instanceof List) {
|
||
|
List list = (List) iterable;
|
||
|
if (list.isEmpty()) {
|
||
|
return null;
|
||
|
}
|
||
|
return (T) list.get(0);
|
||
|
}
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (it.hasNext()) {
|
||
|
return it.next();
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
public static final <T> T firstOrNull(List<? extends T> list) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
if (list.isEmpty()) {
|
||
|
return null;
|
||
|
}
|
||
|
return list.get(0);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Type inference failed for: r0v3, types: [T, java.lang.Object] */
|
||
|
public static final <T> T firstOrNull(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
for (T t : iterable) {
|
||
|
if (predicate.invoke(t).booleanValue()) {
|
||
|
return t;
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
private static final <T> T getOrElse(List<? extends T> list, int i, Function1<? super Integer, ? extends T> defaultValue) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(defaultValue, "defaultValue");
|
||
|
return (i < 0 || i > CollectionsKt.getLastIndex(list)) ? defaultValue.invoke(Integer.valueOf(i)) : list.get(i);
|
||
|
}
|
||
|
|
||
|
public static final <T> T getOrNull(List<? extends T> list, int i) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
if (i < 0 || i > CollectionsKt.getLastIndex(list)) {
|
||
|
return null;
|
||
|
}
|
||
|
return list.get(i);
|
||
|
}
|
||
|
|
||
|
public static final <T> int indexOf(Iterable<? extends T> iterable, T t) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (iterable instanceof List) {
|
||
|
return ((List) iterable).indexOf(t);
|
||
|
}
|
||
|
int i = 0;
|
||
|
for (T t2 : iterable) {
|
||
|
if (i < 0) {
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
if (Intrinsics.areEqual(t, t2)) {
|
||
|
return i;
|
||
|
}
|
||
|
i++;
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
public static final <T> int indexOf(List<? extends T> list, T t) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
return list.indexOf(t);
|
||
|
}
|
||
|
|
||
|
public static final <T> int indexOfFirst(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
int i = 0;
|
||
|
for (T t : iterable) {
|
||
|
if (i < 0) {
|
||
|
if (!PlatformImplementationsKt.apiVersionIsAtLeast(1, 3, 0)) {
|
||
|
throw new ArithmeticException("Index overflow has happened.");
|
||
|
}
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
if (predicate.invoke(t).booleanValue()) {
|
||
|
return i;
|
||
|
}
|
||
|
i++;
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
public static final <T> int indexOfFirst(List<? extends T> list, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
Iterator<? extends T> it = list.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
if (predicate.invoke(it.next()).booleanValue()) {
|
||
|
return i;
|
||
|
}
|
||
|
i++;
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
public static final <T> int indexOfLast(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
int i = -1;
|
||
|
int i2 = 0;
|
||
|
for (T t : iterable) {
|
||
|
if (i2 < 0) {
|
||
|
if (!PlatformImplementationsKt.apiVersionIsAtLeast(1, 3, 0)) {
|
||
|
throw new ArithmeticException("Index overflow has happened.");
|
||
|
}
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
if (predicate.invoke(t).booleanValue()) {
|
||
|
i = i2;
|
||
|
}
|
||
|
i2++;
|
||
|
}
|
||
|
return i;
|
||
|
}
|
||
|
|
||
|
public static final <T> int indexOfLast(List<? extends T> list, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
ListIterator<? extends T> listIterator = list.listIterator(list.size());
|
||
|
while (listIterator.hasPrevious()) {
|
||
|
if (predicate.invoke(listIterator.previous()).booleanValue()) {
|
||
|
return listIterator.nextIndex();
|
||
|
}
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
public static final <T> T last(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (iterable instanceof List) {
|
||
|
return (T) CollectionsKt.last((List) iterable);
|
||
|
}
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException("Collection is empty.");
|
||
|
}
|
||
|
T next = it.next();
|
||
|
while (it.hasNext()) {
|
||
|
next = it.next();
|
||
|
}
|
||
|
return next;
|
||
|
}
|
||
|
|
||
|
public static final <T> T last(List<? extends T> list) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
if (list.isEmpty()) {
|
||
|
throw new NoSuchElementException("List is empty.");
|
||
|
}
|
||
|
return list.get(CollectionsKt.getLastIndex(list));
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
/* JADX WARN: Type inference failed for: r2v1, types: [java.lang.Object] */
|
||
|
public static final <T> T last(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
T t = null;
|
||
|
boolean z = false;
|
||
|
for (T t2 : iterable) {
|
||
|
if (predicate.invoke(t2).booleanValue()) {
|
||
|
z = true;
|
||
|
t = t2;
|
||
|
}
|
||
|
}
|
||
|
if (z) {
|
||
|
return t;
|
||
|
}
|
||
|
throw new NoSuchElementException("Collection contains no element matching the predicate.");
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Type inference failed for: r0v4, types: [T, java.lang.Object] */
|
||
|
public static final <T> T last(List<? extends T> list, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
ListIterator<? extends T> listIterator = list.listIterator(list.size());
|
||
|
while (listIterator.hasPrevious()) {
|
||
|
T previous = listIterator.previous();
|
||
|
if (predicate.invoke(previous).booleanValue()) {
|
||
|
return previous;
|
||
|
}
|
||
|
}
|
||
|
throw new NoSuchElementException("List contains no element matching the predicate.");
|
||
|
}
|
||
|
|
||
|
public static final <T> int lastIndexOf(Iterable<? extends T> iterable, T t) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (iterable instanceof List) {
|
||
|
return ((List) iterable).lastIndexOf(t);
|
||
|
}
|
||
|
int i = -1;
|
||
|
int i2 = 0;
|
||
|
for (T t2 : iterable) {
|
||
|
if (i2 < 0) {
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
if (Intrinsics.areEqual(t, t2)) {
|
||
|
i = i2;
|
||
|
}
|
||
|
i2++;
|
||
|
}
|
||
|
return i;
|
||
|
}
|
||
|
|
||
|
public static final <T> int lastIndexOf(List<? extends T> list, T t) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
return list.lastIndexOf(t);
|
||
|
}
|
||
|
|
||
|
public static final <T> T lastOrNull(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (iterable instanceof List) {
|
||
|
List list = (List) iterable;
|
||
|
if (list.isEmpty()) {
|
||
|
return null;
|
||
|
}
|
||
|
return (T) list.get(list.size() - 1);
|
||
|
}
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
T next = it.next();
|
||
|
while (it.hasNext()) {
|
||
|
next = it.next();
|
||
|
}
|
||
|
return next;
|
||
|
}
|
||
|
|
||
|
public static final <T> T lastOrNull(List<? extends T> list) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
if (list.isEmpty()) {
|
||
|
return null;
|
||
|
}
|
||
|
return list.get(list.size() - 1);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
/* JADX WARN: Type inference failed for: r1v1, types: [java.lang.Object] */
|
||
|
public static final <T> T lastOrNull(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
T t = null;
|
||
|
for (T t2 : iterable) {
|
||
|
if (predicate.invoke(t2).booleanValue()) {
|
||
|
t = t2;
|
||
|
}
|
||
|
}
|
||
|
return t;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Type inference failed for: r0v4, types: [T, java.lang.Object] */
|
||
|
public static final <T> T lastOrNull(List<? extends T> list, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
ListIterator<? extends T> listIterator = list.listIterator(list.size());
|
||
|
while (listIterator.hasPrevious()) {
|
||
|
T previous = listIterator.previous();
|
||
|
if (predicate.invoke(previous).booleanValue()) {
|
||
|
return previous;
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
private static final <T> T random(Collection<? extends T> collection) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
return (T) CollectionsKt.random(collection, Random.INSTANCE);
|
||
|
}
|
||
|
|
||
|
public static final <T> T random(Collection<? extends T> collection, Random random) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(random, "random");
|
||
|
if (collection.isEmpty()) {
|
||
|
throw new NoSuchElementException("Collection is empty.");
|
||
|
}
|
||
|
return (T) CollectionsKt.elementAt(collection, random.nextInt(collection.size()));
|
||
|
}
|
||
|
|
||
|
private static final <T> T randomOrNull(Collection<? extends T> collection) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
return (T) CollectionsKt.randomOrNull(collection, Random.INSTANCE);
|
||
|
}
|
||
|
|
||
|
public static final <T> T randomOrNull(Collection<? extends T> collection, Random random) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(random, "random");
|
||
|
if (collection.isEmpty()) {
|
||
|
return null;
|
||
|
}
|
||
|
return (T) CollectionsKt.elementAt(collection, random.nextInt(collection.size()));
|
||
|
}
|
||
|
|
||
|
public static final <T> T single(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (iterable instanceof List) {
|
||
|
return (T) CollectionsKt.single((List) iterable);
|
||
|
}
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException("Collection is empty.");
|
||
|
}
|
||
|
T next = it.next();
|
||
|
if (it.hasNext()) {
|
||
|
throw new IllegalArgumentException("Collection has more than one element.");
|
||
|
}
|
||
|
return next;
|
||
|
}
|
||
|
|
||
|
public static final <T> T single(List<? extends T> list) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
int size = list.size();
|
||
|
if (size == 0) {
|
||
|
throw new NoSuchElementException("List is empty.");
|
||
|
}
|
||
|
if (size == 1) {
|
||
|
return list.get(0);
|
||
|
}
|
||
|
throw new IllegalArgumentException("List has more than one element.");
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
/* JADX WARN: Type inference failed for: r2v1, types: [java.lang.Object] */
|
||
|
public static final <T> T single(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
T t = null;
|
||
|
boolean z = false;
|
||
|
for (T t2 : iterable) {
|
||
|
if (predicate.invoke(t2).booleanValue()) {
|
||
|
if (z) {
|
||
|
throw new IllegalArgumentException("Collection contains more than one matching element.");
|
||
|
}
|
||
|
z = true;
|
||
|
t = t2;
|
||
|
}
|
||
|
}
|
||
|
if (z) {
|
||
|
return t;
|
||
|
}
|
||
|
throw new NoSuchElementException("Collection contains no element matching the predicate.");
|
||
|
}
|
||
|
|
||
|
public static final <T> T singleOrNull(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (iterable instanceof List) {
|
||
|
List list = (List) iterable;
|
||
|
if (list.size() == 1) {
|
||
|
return (T) list.get(0);
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
T next = it.next();
|
||
|
if (it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
return next;
|
||
|
}
|
||
|
|
||
|
public static final <T> T singleOrNull(List<? extends T> list) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
if (list.size() == 1) {
|
||
|
return list.get(0);
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
/* JADX WARN: Type inference failed for: r3v1, types: [java.lang.Object] */
|
||
|
public static final <T> T singleOrNull(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
boolean z = false;
|
||
|
T t = null;
|
||
|
for (T t2 : iterable) {
|
||
|
if (predicate.invoke(t2).booleanValue()) {
|
||
|
if (z) {
|
||
|
return null;
|
||
|
}
|
||
|
z = true;
|
||
|
t = t2;
|
||
|
}
|
||
|
}
|
||
|
if (z) {
|
||
|
return t;
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> drop(Iterable<? extends T> iterable, int i) {
|
||
|
ArrayList arrayList;
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (i < 0) {
|
||
|
throw new IllegalArgumentException(("Requested element count " + i + " is less than zero.").toString());
|
||
|
}
|
||
|
if (i == 0) {
|
||
|
return CollectionsKt.toList(iterable);
|
||
|
}
|
||
|
if (iterable instanceof Collection) {
|
||
|
Collection collection = (Collection) iterable;
|
||
|
int size = collection.size() - i;
|
||
|
if (size <= 0) {
|
||
|
return CollectionsKt.emptyList();
|
||
|
}
|
||
|
if (size == 1) {
|
||
|
return CollectionsKt.listOf(CollectionsKt.last(iterable));
|
||
|
}
|
||
|
arrayList = new ArrayList(size);
|
||
|
if (iterable instanceof List) {
|
||
|
if (iterable instanceof RandomAccess) {
|
||
|
int size2 = collection.size();
|
||
|
while (i < size2) {
|
||
|
arrayList.add(((List) iterable).get(i));
|
||
|
i++;
|
||
|
}
|
||
|
} else {
|
||
|
ListIterator listIterator = ((List) iterable).listIterator(i);
|
||
|
while (listIterator.hasNext()) {
|
||
|
arrayList.add(listIterator.next());
|
||
|
}
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
} else {
|
||
|
arrayList = new ArrayList();
|
||
|
}
|
||
|
int i2 = 0;
|
||
|
for (T t : iterable) {
|
||
|
if (i2 >= i) {
|
||
|
arrayList.add(t);
|
||
|
} else {
|
||
|
i2++;
|
||
|
}
|
||
|
}
|
||
|
return CollectionsKt.optimizeReadOnlyList(arrayList);
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> dropLast(List<? extends T> list, int i) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
if (i < 0) {
|
||
|
throw new IllegalArgumentException(("Requested element count " + i + " is less than zero.").toString());
|
||
|
}
|
||
|
return CollectionsKt.take(list, RangesKt.coerceAtLeast(list.size() - i, 0));
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> dropLastWhile(List<? extends T> list, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
if (!list.isEmpty()) {
|
||
|
ListIterator<? extends T> listIterator = list.listIterator(list.size());
|
||
|
while (listIterator.hasPrevious()) {
|
||
|
if (!predicate.invoke(listIterator.previous()).booleanValue()) {
|
||
|
return CollectionsKt.take(list, listIterator.nextIndex() + 1);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return CollectionsKt.emptyList();
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> dropWhile(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
boolean z = false;
|
||
|
for (T t : iterable) {
|
||
|
if (z) {
|
||
|
arrayList.add(t);
|
||
|
} else if (!predicate.invoke(t).booleanValue()) {
|
||
|
arrayList.add(t);
|
||
|
z = true;
|
||
|
}
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> filter(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
for (T t : iterable) {
|
||
|
if (predicate.invoke(t).booleanValue()) {
|
||
|
arrayList.add(t);
|
||
|
}
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> filterIndexed(Iterable<? extends T> iterable, Function2<? super Integer, ? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
int i = 0;
|
||
|
for (T t : iterable) {
|
||
|
int i2 = i + 1;
|
||
|
if (i < 0) {
|
||
|
if (!PlatformImplementationsKt.apiVersionIsAtLeast(1, 3, 0)) {
|
||
|
throw new ArithmeticException("Index overflow has happened.");
|
||
|
}
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
if (predicate.invoke(Integer.valueOf(i), t).booleanValue()) {
|
||
|
arrayList.add(t);
|
||
|
}
|
||
|
i = i2;
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ <R> List<R> filterIsInstance(Iterable<?> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
for (Object obj : iterable) {
|
||
|
Intrinsics.reifiedOperationMarker(3, "R");
|
||
|
if (obj instanceof Object) {
|
||
|
arrayList.add(obj);
|
||
|
}
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ <R, C extends Collection<? super R>> C filterIsInstanceTo(Iterable<?> iterable, C destination) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
for (Object obj : iterable) {
|
||
|
Intrinsics.reifiedOperationMarker(3, "R");
|
||
|
if (obj instanceof Object) {
|
||
|
destination.add(obj);
|
||
|
}
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> filterNot(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
for (T t : iterable) {
|
||
|
if (!predicate.invoke(t).booleanValue()) {
|
||
|
arrayList.add(t);
|
||
|
}
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> filterNotNull(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
return (List) CollectionsKt.filterNotNullTo(iterable, new ArrayList());
|
||
|
}
|
||
|
|
||
|
public static final <C extends Collection<? super T>, T> C filterNotNullTo(Iterable<? extends T> iterable, C destination) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
for (T t : iterable) {
|
||
|
if (t != null) {
|
||
|
destination.add(t);
|
||
|
}
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <T, C extends Collection<? super T>> C filterNotTo(Iterable<? extends T> iterable, C destination, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
for (T t : iterable) {
|
||
|
if (!predicate.invoke(t).booleanValue()) {
|
||
|
destination.add(t);
|
||
|
}
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <T, C extends Collection<? super T>> C filterTo(Iterable<? extends T> iterable, C destination, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
for (T t : iterable) {
|
||
|
if (predicate.invoke(t).booleanValue()) {
|
||
|
destination.add(t);
|
||
|
}
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> slice(List<? extends T> list, IntRange indices) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(indices, "indices");
|
||
|
return indices.isEmpty() ? CollectionsKt.emptyList() : CollectionsKt.toList(list.subList(indices.getStart().intValue(), indices.getEndInclusive().intValue() + 1));
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> slice(List<? extends T> list, Iterable<Integer> indices) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(indices, "indices");
|
||
|
int collectionSizeOrDefault = CollectionsKt.collectionSizeOrDefault(indices, 10);
|
||
|
if (collectionSizeOrDefault == 0) {
|
||
|
return CollectionsKt.emptyList();
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList(collectionSizeOrDefault);
|
||
|
Iterator<Integer> it = indices.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
arrayList.add(list.get(it.next().intValue()));
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> take(Iterable<? extends T> iterable, int i) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (i < 0) {
|
||
|
throw new IllegalArgumentException(("Requested element count " + i + " is less than zero.").toString());
|
||
|
}
|
||
|
if (i == 0) {
|
||
|
return CollectionsKt.emptyList();
|
||
|
}
|
||
|
if (iterable instanceof Collection) {
|
||
|
if (i >= ((Collection) iterable).size()) {
|
||
|
return CollectionsKt.toList(iterable);
|
||
|
}
|
||
|
if (i == 1) {
|
||
|
return CollectionsKt.listOf(CollectionsKt.first(iterable));
|
||
|
}
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList(i);
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
int i2 = 0;
|
||
|
while (it.hasNext()) {
|
||
|
arrayList.add(it.next());
|
||
|
i2++;
|
||
|
if (i2 == i) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return CollectionsKt.optimizeReadOnlyList(arrayList);
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> takeLast(List<? extends T> list, int i) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
if (i < 0) {
|
||
|
throw new IllegalArgumentException(("Requested element count " + i + " is less than zero.").toString());
|
||
|
}
|
||
|
if (i == 0) {
|
||
|
return CollectionsKt.emptyList();
|
||
|
}
|
||
|
int size = list.size();
|
||
|
if (i >= size) {
|
||
|
return CollectionsKt.toList(list);
|
||
|
}
|
||
|
if (i == 1) {
|
||
|
return CollectionsKt.listOf(CollectionsKt.last((List) list));
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList(i);
|
||
|
if (list instanceof RandomAccess) {
|
||
|
for (int i2 = size - i; i2 < size; i2++) {
|
||
|
arrayList.add(list.get(i2));
|
||
|
}
|
||
|
} else {
|
||
|
ListIterator<? extends T> listIterator = list.listIterator(size - i);
|
||
|
while (listIterator.hasNext()) {
|
||
|
arrayList.add(listIterator.next());
|
||
|
}
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> takeLastWhile(List<? extends T> list, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
if (list.isEmpty()) {
|
||
|
return CollectionsKt.emptyList();
|
||
|
}
|
||
|
ListIterator<? extends T> listIterator = list.listIterator(list.size());
|
||
|
while (listIterator.hasPrevious()) {
|
||
|
if (!predicate.invoke(listIterator.previous()).booleanValue()) {
|
||
|
listIterator.next();
|
||
|
int size = list.size() - listIterator.nextIndex();
|
||
|
if (size == 0) {
|
||
|
return CollectionsKt.emptyList();
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList(size);
|
||
|
while (listIterator.hasNext()) {
|
||
|
arrayList.add(listIterator.next());
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
}
|
||
|
return CollectionsKt.toList(list);
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> takeWhile(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
for (T t : iterable) {
|
||
|
if (!predicate.invoke(t).booleanValue()) {
|
||
|
break;
|
||
|
}
|
||
|
arrayList.add(t);
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> reversed(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if ((iterable instanceof Collection) && ((Collection) iterable).size() <= 1) {
|
||
|
return CollectionsKt.toList(iterable);
|
||
|
}
|
||
|
List<T> mutableList = CollectionsKt.toMutableList(iterable);
|
||
|
CollectionsKt.reverse(mutableList);
|
||
|
return mutableList;
|
||
|
}
|
||
|
|
||
|
public static final <T> void shuffle(List<T> list, Random random) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(random, "random");
|
||
|
for (int lastIndex = CollectionsKt.getLastIndex(list); lastIndex > 0; lastIndex--) {
|
||
|
int nextInt = random.nextInt(lastIndex + 1);
|
||
|
list.set(nextInt, list.set(lastIndex, list.get(nextInt)));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static final <T, R extends Comparable<? super R>> void sortBy(List<T> list, Function1<? super T, ? extends R> selector) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
if (list.size() > 1) {
|
||
|
CollectionsKt.sortWith(list, new ComparisonsKt__ComparisonsKt$compareBy$2(selector));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static final <T, R extends Comparable<? super R>> void sortByDescending(List<T> list, Function1<? super T, ? extends R> selector) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
if (list.size() > 1) {
|
||
|
CollectionsKt.sortWith(list, new ComparisonsKt__ComparisonsKt$compareByDescending$1(selector));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static final <T extends Comparable<? super T>> void sortDescending(List<T> list) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
CollectionsKt.sortWith(list, ComparisonsKt.reverseOrder());
|
||
|
}
|
||
|
|
||
|
public static final <T extends Comparable<? super T>> List<T> sorted(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (iterable instanceof Collection) {
|
||
|
Collection collection = (Collection) iterable;
|
||
|
if (collection.size() <= 1) {
|
||
|
return CollectionsKt.toList(iterable);
|
||
|
}
|
||
|
Object[] array = collection.toArray(new Comparable[0]);
|
||
|
ArraysKt.sort(array);
|
||
|
return ArraysKt.asList(array);
|
||
|
}
|
||
|
List<T> mutableList = CollectionsKt.toMutableList(iterable);
|
||
|
CollectionsKt.sort(mutableList);
|
||
|
return mutableList;
|
||
|
}
|
||
|
|
||
|
public static final <T, R extends Comparable<? super R>> List<T> sortedBy(Iterable<? extends T> iterable, Function1<? super T, ? extends R> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
return CollectionsKt.sortedWith(iterable, new ComparisonsKt__ComparisonsKt$compareBy$2(selector));
|
||
|
}
|
||
|
|
||
|
public static final <T, R extends Comparable<? super R>> List<T> sortedByDescending(Iterable<? extends T> iterable, Function1<? super T, ? extends R> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
return CollectionsKt.sortedWith(iterable, new ComparisonsKt__ComparisonsKt$compareByDescending$1(selector));
|
||
|
}
|
||
|
|
||
|
public static final <T extends Comparable<? super T>> List<T> sortedDescending(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
return CollectionsKt.sortedWith(iterable, ComparisonsKt.reverseOrder());
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public static final <T> List<T> sortedWith(Iterable<? extends T> iterable, Comparator<? super T> comparator) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(comparator, "comparator");
|
||
|
if (iterable instanceof Collection) {
|
||
|
Collection collection = (Collection) iterable;
|
||
|
if (collection.size() <= 1) {
|
||
|
return CollectionsKt.toList(iterable);
|
||
|
}
|
||
|
Object[] array = collection.toArray(new Object[0]);
|
||
|
ArraysKt.sortWith(array, comparator);
|
||
|
return ArraysKt.asList(array);
|
||
|
}
|
||
|
List<T> mutableList = CollectionsKt.toMutableList(iterable);
|
||
|
CollectionsKt.sortWith(mutableList, comparator);
|
||
|
return mutableList;
|
||
|
}
|
||
|
|
||
|
public static final boolean[] toBooleanArray(Collection<Boolean> collection) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
boolean[] zArr = new boolean[collection.size()];
|
||
|
Iterator<Boolean> it = collection.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
zArr[i] = it.next().booleanValue();
|
||
|
i++;
|
||
|
}
|
||
|
return zArr;
|
||
|
}
|
||
|
|
||
|
public static final byte[] toByteArray(Collection<Byte> collection) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
byte[] bArr = new byte[collection.size()];
|
||
|
Iterator<Byte> it = collection.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
bArr[i] = it.next().byteValue();
|
||
|
i++;
|
||
|
}
|
||
|
return bArr;
|
||
|
}
|
||
|
|
||
|
public static final char[] toCharArray(Collection<Character> collection) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
char[] cArr = new char[collection.size()];
|
||
|
Iterator<Character> it = collection.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
cArr[i] = it.next().charValue();
|
||
|
i++;
|
||
|
}
|
||
|
return cArr;
|
||
|
}
|
||
|
|
||
|
public static final double[] toDoubleArray(Collection<Double> collection) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
double[] dArr = new double[collection.size()];
|
||
|
Iterator<Double> it = collection.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
dArr[i] = it.next().doubleValue();
|
||
|
i++;
|
||
|
}
|
||
|
return dArr;
|
||
|
}
|
||
|
|
||
|
public static final float[] toFloatArray(Collection<Float> collection) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
float[] fArr = new float[collection.size()];
|
||
|
Iterator<Float> it = collection.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
fArr[i] = it.next().floatValue();
|
||
|
i++;
|
||
|
}
|
||
|
return fArr;
|
||
|
}
|
||
|
|
||
|
public static final int[] toIntArray(Collection<Integer> collection) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
int[] iArr = new int[collection.size()];
|
||
|
Iterator<Integer> it = collection.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
iArr[i] = it.next().intValue();
|
||
|
i++;
|
||
|
}
|
||
|
return iArr;
|
||
|
}
|
||
|
|
||
|
public static final long[] toLongArray(Collection<Long> collection) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
long[] jArr = new long[collection.size()];
|
||
|
Iterator<Long> it = collection.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
jArr[i] = it.next().longValue();
|
||
|
i++;
|
||
|
}
|
||
|
return jArr;
|
||
|
}
|
||
|
|
||
|
public static final short[] toShortArray(Collection<Short> collection) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
short[] sArr = new short[collection.size()];
|
||
|
Iterator<Short> it = collection.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
sArr[i] = it.next().shortValue();
|
||
|
i++;
|
||
|
}
|
||
|
return sArr;
|
||
|
}
|
||
|
|
||
|
public static final <T, K, V> Map<K, V> associate(Iterable<? extends T> iterable, Function1<? super T, ? extends Pair<? extends K, ? extends V>> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
LinkedHashMap linkedHashMap = new LinkedHashMap(RangesKt.coerceAtLeast(MapsKt.mapCapacity(CollectionsKt.collectionSizeOrDefault(iterable, 10)), 16));
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
Pair<? extends K, ? extends V> invoke = transform.invoke(it.next());
|
||
|
linkedHashMap.put(invoke.getFirst(), invoke.getSecond());
|
||
|
}
|
||
|
return linkedHashMap;
|
||
|
}
|
||
|
|
||
|
public static final <T, K> Map<K, T> associateBy(Iterable<? extends T> iterable, Function1<? super T, ? extends K> keySelector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(keySelector, "keySelector");
|
||
|
LinkedHashMap linkedHashMap = new LinkedHashMap(RangesKt.coerceAtLeast(MapsKt.mapCapacity(CollectionsKt.collectionSizeOrDefault(iterable, 10)), 16));
|
||
|
for (T t : iterable) {
|
||
|
linkedHashMap.put(keySelector.invoke(t), t);
|
||
|
}
|
||
|
return linkedHashMap;
|
||
|
}
|
||
|
|
||
|
public static final <T, K, V> Map<K, V> associateBy(Iterable<? extends T> iterable, Function1<? super T, ? extends K> keySelector, Function1<? super T, ? extends V> valueTransform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(keySelector, "keySelector");
|
||
|
Intrinsics.checkNotNullParameter(valueTransform, "valueTransform");
|
||
|
LinkedHashMap linkedHashMap = new LinkedHashMap(RangesKt.coerceAtLeast(MapsKt.mapCapacity(CollectionsKt.collectionSizeOrDefault(iterable, 10)), 16));
|
||
|
for (T t : iterable) {
|
||
|
linkedHashMap.put(keySelector.invoke(t), valueTransform.invoke(t));
|
||
|
}
|
||
|
return linkedHashMap;
|
||
|
}
|
||
|
|
||
|
public static final <T, K, M extends Map<? super K, ? super T>> M associateByTo(Iterable<? extends T> iterable, M destination, Function1<? super T, ? extends K> keySelector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Intrinsics.checkNotNullParameter(keySelector, "keySelector");
|
||
|
for (T t : iterable) {
|
||
|
destination.put(keySelector.invoke(t), t);
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <T, K, V, M extends Map<? super K, ? super V>> M associateByTo(Iterable<? extends T> iterable, M destination, Function1<? super T, ? extends K> keySelector, Function1<? super T, ? extends V> valueTransform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Intrinsics.checkNotNullParameter(keySelector, "keySelector");
|
||
|
Intrinsics.checkNotNullParameter(valueTransform, "valueTransform");
|
||
|
for (T t : iterable) {
|
||
|
destination.put(keySelector.invoke(t), valueTransform.invoke(t));
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <T, K, V, M extends Map<? super K, ? super V>> M associateTo(Iterable<? extends T> iterable, M destination, Function1<? super T, ? extends Pair<? extends K, ? extends V>> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
Pair<? extends K, ? extends V> invoke = transform.invoke(it.next());
|
||
|
destination.put(invoke.getFirst(), invoke.getSecond());
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <K, V> Map<K, V> associateWith(Iterable<? extends K> iterable, Function1<? super K, ? extends V> valueSelector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(valueSelector, "valueSelector");
|
||
|
LinkedHashMap linkedHashMap = new LinkedHashMap(RangesKt.coerceAtLeast(MapsKt.mapCapacity(CollectionsKt.collectionSizeOrDefault(iterable, 10)), 16));
|
||
|
for (K k : iterable) {
|
||
|
linkedHashMap.put(k, valueSelector.invoke(k));
|
||
|
}
|
||
|
return linkedHashMap;
|
||
|
}
|
||
|
|
||
|
public static final <K, V, M extends Map<? super K, ? super V>> M associateWithTo(Iterable<? extends K> iterable, M destination, Function1<? super K, ? extends V> valueSelector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Intrinsics.checkNotNullParameter(valueSelector, "valueSelector");
|
||
|
for (K k : iterable) {
|
||
|
destination.put(k, valueSelector.invoke(k));
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <T, C extends Collection<? super T>> C toCollection(Iterable<? extends T> iterable, C destination) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
destination.add(it.next());
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <T> HashSet<T> toHashSet(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
return (HashSet) CollectionsKt.toCollection(iterable, new HashSet(MapsKt.mapCapacity(CollectionsKt.collectionSizeOrDefault(iterable, 12))));
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> toList(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (iterable instanceof Collection) {
|
||
|
Collection collection = (Collection) iterable;
|
||
|
int size = collection.size();
|
||
|
if (size == 0) {
|
||
|
return CollectionsKt.emptyList();
|
||
|
}
|
||
|
if (size != 1) {
|
||
|
return CollectionsKt.toMutableList(collection);
|
||
|
}
|
||
|
return CollectionsKt.listOf(iterable instanceof List ? ((List) iterable).get(0) : iterable.iterator().next());
|
||
|
}
|
||
|
return CollectionsKt.optimizeReadOnlyList(CollectionsKt.toMutableList(iterable));
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> toMutableList(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (iterable instanceof Collection) {
|
||
|
return CollectionsKt.toMutableList((Collection) iterable);
|
||
|
}
|
||
|
return (List) CollectionsKt.toCollection(iterable, new ArrayList());
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> toMutableList(Collection<? extends T> collection) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
return new ArrayList(collection);
|
||
|
}
|
||
|
|
||
|
public static final <T> Set<T> toSet(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (iterable instanceof Collection) {
|
||
|
Collection collection = (Collection) iterable;
|
||
|
int size = collection.size();
|
||
|
if (size == 0) {
|
||
|
return SetsKt.emptySet();
|
||
|
}
|
||
|
if (size != 1) {
|
||
|
return (Set) CollectionsKt.toCollection(iterable, new LinkedHashSet(MapsKt.mapCapacity(collection.size())));
|
||
|
}
|
||
|
return SetsKt.setOf(iterable instanceof List ? ((List) iterable).get(0) : iterable.iterator().next());
|
||
|
}
|
||
|
return SetsKt.optimizeReadOnlySet((Set) CollectionsKt.toCollection(iterable, new LinkedHashSet()));
|
||
|
}
|
||
|
|
||
|
public static final <T, R> List<R> flatMap(Iterable<? extends T> iterable, Function1<? super T, ? extends Iterable<? extends R>> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
CollectionsKt.addAll(arrayList, transform.invoke(it.next()));
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T, R> List<R> flatMapSequence(Iterable<? extends T> iterable, Function1<? super T, ? extends Sequence<? extends R>> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
CollectionsKt.addAll(arrayList, transform.invoke(it.next()));
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
private static final <T, R> List<R> flatMapIndexedIterable(Iterable<? extends T> iterable, Function2<? super Integer, ? super T, ? extends Iterable<? extends R>> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
int i = 0;
|
||
|
for (T t : iterable) {
|
||
|
int i2 = i + 1;
|
||
|
if (i < 0) {
|
||
|
if (!PlatformImplementationsKt.apiVersionIsAtLeast(1, 3, 0)) {
|
||
|
throw new ArithmeticException("Index overflow has happened.");
|
||
|
}
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
CollectionsKt.addAll(arrayList, transform.invoke(Integer.valueOf(i), t));
|
||
|
i = i2;
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
private static final <T, R> List<R> flatMapIndexedSequence(Iterable<? extends T> iterable, Function2<? super Integer, ? super T, ? extends Sequence<? extends R>> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
int i = 0;
|
||
|
for (T t : iterable) {
|
||
|
int i2 = i + 1;
|
||
|
if (i < 0) {
|
||
|
if (!PlatformImplementationsKt.apiVersionIsAtLeast(1, 3, 0)) {
|
||
|
throw new ArithmeticException("Index overflow has happened.");
|
||
|
}
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
CollectionsKt.addAll(arrayList, transform.invoke(Integer.valueOf(i), t));
|
||
|
i = i2;
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
private static final <T, R, C extends Collection<? super R>> C flatMapIndexedIterableTo(Iterable<? extends T> iterable, C destination, Function2<? super Integer, ? super T, ? extends Iterable<? extends R>> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
int i = 0;
|
||
|
for (T t : iterable) {
|
||
|
int i2 = i + 1;
|
||
|
if (i < 0) {
|
||
|
if (!PlatformImplementationsKt.apiVersionIsAtLeast(1, 3, 0)) {
|
||
|
throw new ArithmeticException("Index overflow has happened.");
|
||
|
}
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
CollectionsKt.addAll(destination, transform.invoke(Integer.valueOf(i), t));
|
||
|
i = i2;
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
private static final <T, R, C extends Collection<? super R>> C flatMapIndexedSequenceTo(Iterable<? extends T> iterable, C destination, Function2<? super Integer, ? super T, ? extends Sequence<? extends R>> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
int i = 0;
|
||
|
for (T t : iterable) {
|
||
|
int i2 = i + 1;
|
||
|
if (i < 0) {
|
||
|
if (!PlatformImplementationsKt.apiVersionIsAtLeast(1, 3, 0)) {
|
||
|
throw new ArithmeticException("Index overflow has happened.");
|
||
|
}
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
CollectionsKt.addAll(destination, transform.invoke(Integer.valueOf(i), t));
|
||
|
i = i2;
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <T, R, C extends Collection<? super R>> C flatMapTo(Iterable<? extends T> iterable, C destination, Function1<? super T, ? extends Iterable<? extends R>> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
CollectionsKt.addAll(destination, transform.invoke(it.next()));
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <T, R, C extends Collection<? super R>> C flatMapSequenceTo(Iterable<? extends T> iterable, C destination, Function1<? super T, ? extends Sequence<? extends R>> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
CollectionsKt.addAll(destination, transform.invoke(it.next()));
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <T, K> Map<K, List<T>> groupBy(Iterable<? extends T> iterable, Function1<? super T, ? extends K> keySelector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(keySelector, "keySelector");
|
||
|
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
||
|
for (T t : iterable) {
|
||
|
K invoke = keySelector.invoke(t);
|
||
|
Object obj = linkedHashMap.get(invoke);
|
||
|
if (obj == null) {
|
||
|
obj = (List) new ArrayList();
|
||
|
linkedHashMap.put(invoke, obj);
|
||
|
}
|
||
|
((List) obj).add(t);
|
||
|
}
|
||
|
return linkedHashMap;
|
||
|
}
|
||
|
|
||
|
public static final <T, K, V> Map<K, List<V>> groupBy(Iterable<? extends T> iterable, Function1<? super T, ? extends K> keySelector, Function1<? super T, ? extends V> valueTransform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(keySelector, "keySelector");
|
||
|
Intrinsics.checkNotNullParameter(valueTransform, "valueTransform");
|
||
|
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
||
|
for (T t : iterable) {
|
||
|
K invoke = keySelector.invoke(t);
|
||
|
ArrayList arrayList = linkedHashMap.get(invoke);
|
||
|
if (arrayList == null) {
|
||
|
arrayList = new ArrayList();
|
||
|
linkedHashMap.put(invoke, arrayList);
|
||
|
}
|
||
|
arrayList.add(valueTransform.invoke(t));
|
||
|
}
|
||
|
return linkedHashMap;
|
||
|
}
|
||
|
|
||
|
public static final <T, K, M extends Map<? super K, List<T>>> M groupByTo(Iterable<? extends T> iterable, M destination, Function1<? super T, ? extends K> keySelector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Intrinsics.checkNotNullParameter(keySelector, "keySelector");
|
||
|
for (T t : iterable) {
|
||
|
K invoke = keySelector.invoke(t);
|
||
|
Object obj = destination.get(invoke);
|
||
|
if (obj == null) {
|
||
|
obj = (List) new ArrayList();
|
||
|
destination.put(invoke, obj);
|
||
|
}
|
||
|
((List) obj).add(t);
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public static final <T, K, V, M extends Map<? super K, List<V>>> M groupByTo(Iterable<? extends T> iterable, M destination, Function1<? super T, ? extends K> keySelector, Function1<? super T, ? extends V> valueTransform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Intrinsics.checkNotNullParameter(keySelector, "keySelector");
|
||
|
Intrinsics.checkNotNullParameter(valueTransform, "valueTransform");
|
||
|
for (T t : iterable) {
|
||
|
K invoke = keySelector.invoke(t);
|
||
|
Object obj = destination.get(invoke);
|
||
|
if (obj == null) {
|
||
|
obj = (List) new ArrayList();
|
||
|
destination.put(invoke, obj);
|
||
|
}
|
||
|
((List) obj).add(valueTransform.invoke(t));
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <T, K> Grouping<T, K> groupingBy(final Iterable<? extends T> iterable, final Function1<? super T, ? extends K> keySelector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(keySelector, "keySelector");
|
||
|
return new Grouping<T, K>() { // from class: kotlin.collections.CollectionsKt___CollectionsKt$groupingBy$1
|
||
|
@Override // kotlin.collections.Grouping
|
||
|
public Iterator<T> sourceIterator() {
|
||
|
return iterable.iterator();
|
||
|
}
|
||
|
|
||
|
@Override // kotlin.collections.Grouping
|
||
|
public K keyOf(T element) {
|
||
|
return keySelector.invoke(element);
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
public static final <T, R> List<R> map(Iterable<? extends T> iterable, Function1<? super T, ? extends R> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
ArrayList arrayList = new ArrayList(CollectionsKt.collectionSizeOrDefault(iterable, 10));
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
arrayList.add(transform.invoke(it.next()));
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T, R> List<R> mapIndexed(Iterable<? extends T> iterable, Function2<? super Integer, ? super T, ? extends R> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
ArrayList arrayList = new ArrayList(CollectionsKt.collectionSizeOrDefault(iterable, 10));
|
||
|
int i = 0;
|
||
|
for (T t : iterable) {
|
||
|
int i2 = i + 1;
|
||
|
if (i < 0) {
|
||
|
if (!PlatformImplementationsKt.apiVersionIsAtLeast(1, 3, 0)) {
|
||
|
throw new ArithmeticException("Index overflow has happened.");
|
||
|
}
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
arrayList.add(transform.invoke(Integer.valueOf(i), t));
|
||
|
i = i2;
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T, R> List<R> mapIndexedNotNull(Iterable<? extends T> iterable, Function2<? super Integer, ? super T, ? extends R> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
int i = 0;
|
||
|
for (T t : iterable) {
|
||
|
int i2 = i + 1;
|
||
|
if (i < 0) {
|
||
|
if (!PlatformImplementationsKt.apiVersionIsAtLeast(1, 3, 0)) {
|
||
|
throw new ArithmeticException("Index overflow has happened.");
|
||
|
}
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
R invoke = transform.invoke(Integer.valueOf(i), t);
|
||
|
if (invoke != null) {
|
||
|
arrayList.add(invoke);
|
||
|
}
|
||
|
i = i2;
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T, R, C extends Collection<? super R>> C mapIndexedTo(Iterable<? extends T> iterable, C destination, Function2<? super Integer, ? super T, ? extends R> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
int i = 0;
|
||
|
for (T t : iterable) {
|
||
|
int i2 = i + 1;
|
||
|
if (i < 0) {
|
||
|
if (!PlatformImplementationsKt.apiVersionIsAtLeast(1, 3, 0)) {
|
||
|
throw new ArithmeticException("Index overflow has happened.");
|
||
|
}
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
destination.add(transform.invoke(Integer.valueOf(i), t));
|
||
|
i = i2;
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <T, R> List<R> mapNotNull(Iterable<? extends T> iterable, Function1<? super T, ? extends R> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
R invoke = transform.invoke(it.next());
|
||
|
if (invoke != null) {
|
||
|
arrayList.add(invoke);
|
||
|
}
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T, R, C extends Collection<? super R>> C mapTo(Iterable<? extends T> iterable, C destination, Function1<? super T, ? extends R> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
destination.add(transform.invoke(it.next()));
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <T> Iterable<IndexedValue<T>> withIndex(final Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
return new IndexingIterable(new Function0<Iterator<? extends T>>() { // from class: kotlin.collections.CollectionsKt___CollectionsKt$withIndex$1
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
{
|
||
|
super(0);
|
||
|
}
|
||
|
|
||
|
@Override // kotlin.jvm.functions.Function0
|
||
|
public final Iterator<T> invoke() {
|
||
|
return iterable.iterator();
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> distinct(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
return CollectionsKt.toList(CollectionsKt.toMutableSet(iterable));
|
||
|
}
|
||
|
|
||
|
public static final <T, K> List<T> distinctBy(Iterable<? extends T> iterable, Function1<? super T, ? extends K> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
HashSet hashSet = new HashSet();
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
for (T t : iterable) {
|
||
|
if (hashSet.add(selector.invoke(t))) {
|
||
|
arrayList.add(t);
|
||
|
}
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T> Set<T> intersect(Iterable<? extends T> iterable, Iterable<? extends T> other) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(other, "other");
|
||
|
Set<T> mutableSet = CollectionsKt.toMutableSet(iterable);
|
||
|
CollectionsKt.retainAll(mutableSet, other);
|
||
|
return mutableSet;
|
||
|
}
|
||
|
|
||
|
public static final <T> Set<T> subtract(Iterable<? extends T> iterable, Iterable<? extends T> other) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(other, "other");
|
||
|
Set<T> mutableSet = CollectionsKt.toMutableSet(iterable);
|
||
|
CollectionsKt.removeAll(mutableSet, other);
|
||
|
return mutableSet;
|
||
|
}
|
||
|
|
||
|
public static final <T> Set<T> toMutableSet(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
return iterable instanceof Collection ? new LinkedHashSet((Collection) iterable) : (Set) CollectionsKt.toCollection(iterable, new LinkedHashSet());
|
||
|
}
|
||
|
|
||
|
public static final <T> Set<T> union(Iterable<? extends T> iterable, Iterable<? extends T> other) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(other, "other");
|
||
|
Set<T> mutableSet = CollectionsKt.toMutableSet(iterable);
|
||
|
CollectionsKt.addAll(mutableSet, other);
|
||
|
return mutableSet;
|
||
|
}
|
||
|
|
||
|
public static final <T> boolean all(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
if ((iterable instanceof Collection) && ((Collection) iterable).isEmpty()) {
|
||
|
return true;
|
||
|
}
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
if (!predicate.invoke(it.next()).booleanValue()) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public static final <T> boolean any(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
return iterable instanceof Collection ? !((Collection) iterable).isEmpty() : iterable.iterator().hasNext();
|
||
|
}
|
||
|
|
||
|
public static final <T> boolean any(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
if ((iterable instanceof Collection) && ((Collection) iterable).isEmpty()) {
|
||
|
return false;
|
||
|
}
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
if (predicate.invoke(it.next()).booleanValue()) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
public static final <T> int count(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (iterable instanceof Collection) {
|
||
|
return ((Collection) iterable).size();
|
||
|
}
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
it.next();
|
||
|
i++;
|
||
|
if (i < 0) {
|
||
|
CollectionsKt.throwCountOverflow();
|
||
|
}
|
||
|
}
|
||
|
return i;
|
||
|
}
|
||
|
|
||
|
private static final <T> int count(Collection<? extends T> collection) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
return collection.size();
|
||
|
}
|
||
|
|
||
|
public static final <T> int count(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
if ((iterable instanceof Collection) && ((Collection) iterable).isEmpty()) {
|
||
|
return 0;
|
||
|
}
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
if (predicate.invoke(it.next()).booleanValue() && (i = i + 1) < 0) {
|
||
|
if (!PlatformImplementationsKt.apiVersionIsAtLeast(1, 3, 0)) {
|
||
|
throw new ArithmeticException("Count overflow has happened.");
|
||
|
}
|
||
|
CollectionsKt.throwCountOverflow();
|
||
|
}
|
||
|
}
|
||
|
return i;
|
||
|
}
|
||
|
|
||
|
public static final <T, R> R fold(Iterable<? extends T> iterable, R r, Function2<? super R, ? super T, ? extends R> operation) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
r = operation.invoke(r, it.next());
|
||
|
}
|
||
|
return r;
|
||
|
}
|
||
|
|
||
|
public static final <T, R> R foldIndexed(Iterable<? extends T> iterable, R r, Function3<? super Integer, ? super R, ? super T, ? extends R> operation) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
int i = 0;
|
||
|
for (T t : iterable) {
|
||
|
int i2 = i + 1;
|
||
|
if (i < 0) {
|
||
|
if (!PlatformImplementationsKt.apiVersionIsAtLeast(1, 3, 0)) {
|
||
|
throw new ArithmeticException("Index overflow has happened.");
|
||
|
}
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
r = operation.invoke(Integer.valueOf(i), r, t);
|
||
|
i = i2;
|
||
|
}
|
||
|
return r;
|
||
|
}
|
||
|
|
||
|
public static final <T, R> R foldRight(List<? extends T> list, R r, Function2<? super T, ? super R, ? extends R> operation) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
if (!list.isEmpty()) {
|
||
|
ListIterator<? extends T> listIterator = list.listIterator(list.size());
|
||
|
while (listIterator.hasPrevious()) {
|
||
|
r = operation.invoke(listIterator.previous(), r);
|
||
|
}
|
||
|
}
|
||
|
return r;
|
||
|
}
|
||
|
|
||
|
public static final <T, R> R foldRightIndexed(List<? extends T> list, R r, Function3<? super Integer, ? super T, ? super R, ? extends R> operation) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
if (!list.isEmpty()) {
|
||
|
ListIterator<? extends T> listIterator = list.listIterator(list.size());
|
||
|
while (listIterator.hasPrevious()) {
|
||
|
r = operation.invoke(Integer.valueOf(listIterator.previousIndex()), listIterator.previous(), r);
|
||
|
}
|
||
|
}
|
||
|
return r;
|
||
|
}
|
||
|
|
||
|
public static final <T> void forEach(Iterable<? extends T> iterable, Function1<? super T, Unit> action) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(action, "action");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
action.invoke(it.next());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static final <T> void forEachIndexed(Iterable<? extends T> iterable, Function2<? super Integer, ? super T, Unit> action) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(action, "action");
|
||
|
int i = 0;
|
||
|
for (T t : iterable) {
|
||
|
int i2 = i + 1;
|
||
|
if (i < 0) {
|
||
|
if (!PlatformImplementationsKt.apiVersionIsAtLeast(1, 3, 0)) {
|
||
|
throw new ArithmeticException("Index overflow has happened.");
|
||
|
}
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
action.invoke(Integer.valueOf(i), t);
|
||
|
i = i2;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static final double maxOrThrow(Iterable<Double> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Double> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
double doubleValue = it.next().doubleValue();
|
||
|
while (it.hasNext()) {
|
||
|
doubleValue = Math.max(doubleValue, it.next().doubleValue());
|
||
|
}
|
||
|
return doubleValue;
|
||
|
}
|
||
|
|
||
|
/* renamed from: maxOrThrow */
|
||
|
public static final float m6135maxOrThrow(Iterable<Float> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Float> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
float floatValue = it.next().floatValue();
|
||
|
while (it.hasNext()) {
|
||
|
floatValue = Math.max(floatValue, it.next().floatValue());
|
||
|
}
|
||
|
return floatValue;
|
||
|
}
|
||
|
|
||
|
/* renamed from: maxOrThrow */
|
||
|
public static final <T extends Comparable<? super T>> T m6136maxOrThrow(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
T next = it.next();
|
||
|
while (it.hasNext()) {
|
||
|
T next2 = it.next();
|
||
|
if (next.compareTo(next2) < 0) {
|
||
|
next = next2;
|
||
|
}
|
||
|
}
|
||
|
return next;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Type inference failed for: r0v10 */
|
||
|
/* JADX WARN: Type inference failed for: r0v11 */
|
||
|
/* JADX WARN: Type inference failed for: r0v3, types: [T, java.lang.Object] */
|
||
|
/* JADX WARN: Type inference failed for: r0v4 */
|
||
|
/* JADX WARN: Type inference failed for: r0v5, types: [T] */
|
||
|
public static final <T, R extends Comparable<? super R>> T maxByOrThrow(Iterable<? extends T> iterable, Function1<? super T, ? extends R> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
T next = it.next();
|
||
|
if (!it.hasNext()) {
|
||
|
return next;
|
||
|
}
|
||
|
R invoke = selector.invoke(next);
|
||
|
do {
|
||
|
T next2 = it.next();
|
||
|
R invoke2 = selector.invoke(next2);
|
||
|
next = next;
|
||
|
if (invoke.compareTo(invoke2) < 0) {
|
||
|
invoke = invoke2;
|
||
|
next = next2;
|
||
|
}
|
||
|
} while (it.hasNext());
|
||
|
return (T) next;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Type inference failed for: r0v10 */
|
||
|
/* JADX WARN: Type inference failed for: r0v11 */
|
||
|
/* JADX WARN: Type inference failed for: r0v3, types: [T, java.lang.Object] */
|
||
|
/* JADX WARN: Type inference failed for: r0v4 */
|
||
|
/* JADX WARN: Type inference failed for: r0v5, types: [T] */
|
||
|
public static final <T, R extends Comparable<? super R>> T maxByOrNull(Iterable<? extends T> iterable, Function1<? super T, ? extends R> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
T next = it.next();
|
||
|
if (!it.hasNext()) {
|
||
|
return next;
|
||
|
}
|
||
|
R invoke = selector.invoke(next);
|
||
|
do {
|
||
|
T next2 = it.next();
|
||
|
R invoke2 = selector.invoke(next2);
|
||
|
next = next;
|
||
|
if (invoke.compareTo(invoke2) < 0) {
|
||
|
invoke = invoke2;
|
||
|
next = next2;
|
||
|
}
|
||
|
} while (it.hasNext());
|
||
|
return (T) next;
|
||
|
}
|
||
|
|
||
|
private static final <T> double maxOf(Iterable<? extends T> iterable, Function1<? super T, Double> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
double doubleValue = selector.invoke(it.next()).doubleValue();
|
||
|
while (it.hasNext()) {
|
||
|
doubleValue = Math.max(doubleValue, selector.invoke(it.next()).doubleValue());
|
||
|
}
|
||
|
return doubleValue;
|
||
|
}
|
||
|
|
||
|
/* renamed from: maxOf */
|
||
|
private static final <T> float m6129maxOf(Iterable<? extends T> iterable, Function1<? super T, Float> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
float floatValue = selector.invoke(it.next()).floatValue();
|
||
|
while (it.hasNext()) {
|
||
|
floatValue = Math.max(floatValue, selector.invoke(it.next()).floatValue());
|
||
|
}
|
||
|
return floatValue;
|
||
|
}
|
||
|
|
||
|
/* renamed from: maxOf */
|
||
|
private static final <T, R extends Comparable<? super R>> R m6130maxOf(Iterable<? extends T> iterable, Function1<? super T, ? extends R> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
R invoke = selector.invoke(it.next());
|
||
|
while (it.hasNext()) {
|
||
|
R invoke2 = selector.invoke(it.next());
|
||
|
if (invoke.compareTo(invoke2) < 0) {
|
||
|
invoke = invoke2;
|
||
|
}
|
||
|
}
|
||
|
return invoke;
|
||
|
}
|
||
|
|
||
|
/* renamed from: maxOfOrNull */
|
||
|
private static final <T> Double m6131maxOfOrNull(Iterable<? extends T> iterable, Function1<? super T, Double> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
double doubleValue = selector.invoke(it.next()).doubleValue();
|
||
|
while (it.hasNext()) {
|
||
|
doubleValue = Math.max(doubleValue, selector.invoke(it.next()).doubleValue());
|
||
|
}
|
||
|
return Double.valueOf(doubleValue);
|
||
|
}
|
||
|
|
||
|
/* renamed from: maxOfOrNull */
|
||
|
private static final <T> Float m6132maxOfOrNull(Iterable<? extends T> iterable, Function1<? super T, Float> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
float floatValue = selector.invoke(it.next()).floatValue();
|
||
|
while (it.hasNext()) {
|
||
|
floatValue = Math.max(floatValue, selector.invoke(it.next()).floatValue());
|
||
|
}
|
||
|
return Float.valueOf(floatValue);
|
||
|
}
|
||
|
|
||
|
private static final <T, R extends Comparable<? super R>> R maxOfOrNull(Iterable<? extends T> iterable, Function1<? super T, ? extends R> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
R invoke = selector.invoke(it.next());
|
||
|
while (it.hasNext()) {
|
||
|
R invoke2 = selector.invoke(it.next());
|
||
|
if (invoke.compareTo(invoke2) < 0) {
|
||
|
invoke = invoke2;
|
||
|
}
|
||
|
}
|
||
|
return invoke;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
private static final <T, R> R maxOfWith(Iterable<? extends T> iterable, Comparator<? super R> comparator, Function1<? super T, ? extends R> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(comparator, "comparator");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
Object obj = (R) selector.invoke((T) it.next());
|
||
|
while (it.hasNext()) {
|
||
|
Object obj2 = (R) selector.invoke((T) it.next());
|
||
|
if (comparator.compare(obj, obj2) < 0) {
|
||
|
obj = (R) obj2;
|
||
|
}
|
||
|
}
|
||
|
return (R) obj;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
private static final <T, R> R maxOfWithOrNull(Iterable<? extends T> iterable, Comparator<? super R> comparator, Function1<? super T, ? extends R> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(comparator, "comparator");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
Object obj = (R) selector.invoke((T) it.next());
|
||
|
while (it.hasNext()) {
|
||
|
Object obj2 = (R) selector.invoke((T) it.next());
|
||
|
if (comparator.compare(obj, obj2) < 0) {
|
||
|
obj = (R) obj2;
|
||
|
}
|
||
|
}
|
||
|
return (R) obj;
|
||
|
}
|
||
|
|
||
|
/* renamed from: maxOrNull */
|
||
|
public static final Double m6133maxOrNull(Iterable<Double> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Double> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
double doubleValue = it.next().doubleValue();
|
||
|
while (it.hasNext()) {
|
||
|
doubleValue = Math.max(doubleValue, it.next().doubleValue());
|
||
|
}
|
||
|
return Double.valueOf(doubleValue);
|
||
|
}
|
||
|
|
||
|
/* renamed from: maxOrNull */
|
||
|
public static final Float m6134maxOrNull(Iterable<Float> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Float> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
float floatValue = it.next().floatValue();
|
||
|
while (it.hasNext()) {
|
||
|
floatValue = Math.max(floatValue, it.next().floatValue());
|
||
|
}
|
||
|
return Float.valueOf(floatValue);
|
||
|
}
|
||
|
|
||
|
public static final <T extends Comparable<? super T>> T maxOrNull(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
T next = it.next();
|
||
|
while (it.hasNext()) {
|
||
|
T next2 = it.next();
|
||
|
if (next.compareTo(next2) < 0) {
|
||
|
next = next2;
|
||
|
}
|
||
|
}
|
||
|
return next;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public static final <T> T maxWithOrThrow(Iterable<? extends T> iterable, Comparator<? super T> comparator) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(comparator, "comparator");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
Object obj = (T) it.next();
|
||
|
while (it.hasNext()) {
|
||
|
Object obj2 = (T) it.next();
|
||
|
if (comparator.compare(obj, obj2) < 0) {
|
||
|
obj = (T) obj2;
|
||
|
}
|
||
|
}
|
||
|
return (T) obj;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public static final <T> T maxWithOrNull(Iterable<? extends T> iterable, Comparator<? super T> comparator) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(comparator, "comparator");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
Object obj = (T) it.next();
|
||
|
while (it.hasNext()) {
|
||
|
Object obj2 = (T) it.next();
|
||
|
if (comparator.compare(obj, obj2) < 0) {
|
||
|
obj = (T) obj2;
|
||
|
}
|
||
|
}
|
||
|
return (T) obj;
|
||
|
}
|
||
|
|
||
|
public static final double minOrThrow(Iterable<Double> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Double> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
double doubleValue = it.next().doubleValue();
|
||
|
while (it.hasNext()) {
|
||
|
doubleValue = Math.min(doubleValue, it.next().doubleValue());
|
||
|
}
|
||
|
return doubleValue;
|
||
|
}
|
||
|
|
||
|
/* renamed from: minOrThrow */
|
||
|
public static final float m6143minOrThrow(Iterable<Float> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Float> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
float floatValue = it.next().floatValue();
|
||
|
while (it.hasNext()) {
|
||
|
floatValue = Math.min(floatValue, it.next().floatValue());
|
||
|
}
|
||
|
return floatValue;
|
||
|
}
|
||
|
|
||
|
/* renamed from: minOrThrow */
|
||
|
public static final <T extends Comparable<? super T>> T m6144minOrThrow(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
T next = it.next();
|
||
|
while (it.hasNext()) {
|
||
|
T next2 = it.next();
|
||
|
if (next.compareTo(next2) > 0) {
|
||
|
next = next2;
|
||
|
}
|
||
|
}
|
||
|
return next;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Type inference failed for: r0v10 */
|
||
|
/* JADX WARN: Type inference failed for: r0v11 */
|
||
|
/* JADX WARN: Type inference failed for: r0v3, types: [T, java.lang.Object] */
|
||
|
/* JADX WARN: Type inference failed for: r0v4 */
|
||
|
/* JADX WARN: Type inference failed for: r0v5, types: [T] */
|
||
|
public static final <T, R extends Comparable<? super R>> T minByOrThrow(Iterable<? extends T> iterable, Function1<? super T, ? extends R> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
T next = it.next();
|
||
|
if (!it.hasNext()) {
|
||
|
return next;
|
||
|
}
|
||
|
R invoke = selector.invoke(next);
|
||
|
do {
|
||
|
T next2 = it.next();
|
||
|
R invoke2 = selector.invoke(next2);
|
||
|
next = next;
|
||
|
if (invoke.compareTo(invoke2) > 0) {
|
||
|
invoke = invoke2;
|
||
|
next = next2;
|
||
|
}
|
||
|
} while (it.hasNext());
|
||
|
return (T) next;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Type inference failed for: r0v10 */
|
||
|
/* JADX WARN: Type inference failed for: r0v11 */
|
||
|
/* JADX WARN: Type inference failed for: r0v3, types: [T, java.lang.Object] */
|
||
|
/* JADX WARN: Type inference failed for: r0v4 */
|
||
|
/* JADX WARN: Type inference failed for: r0v5, types: [T] */
|
||
|
public static final <T, R extends Comparable<? super R>> T minByOrNull(Iterable<? extends T> iterable, Function1<? super T, ? extends R> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
T next = it.next();
|
||
|
if (!it.hasNext()) {
|
||
|
return next;
|
||
|
}
|
||
|
R invoke = selector.invoke(next);
|
||
|
do {
|
||
|
T next2 = it.next();
|
||
|
R invoke2 = selector.invoke(next2);
|
||
|
next = next;
|
||
|
if (invoke.compareTo(invoke2) > 0) {
|
||
|
invoke = invoke2;
|
||
|
next = next2;
|
||
|
}
|
||
|
} while (it.hasNext());
|
||
|
return (T) next;
|
||
|
}
|
||
|
|
||
|
private static final <T> double minOf(Iterable<? extends T> iterable, Function1<? super T, Double> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
double doubleValue = selector.invoke(it.next()).doubleValue();
|
||
|
while (it.hasNext()) {
|
||
|
doubleValue = Math.min(doubleValue, selector.invoke(it.next()).doubleValue());
|
||
|
}
|
||
|
return doubleValue;
|
||
|
}
|
||
|
|
||
|
/* renamed from: minOf */
|
||
|
private static final <T> float m6137minOf(Iterable<? extends T> iterable, Function1<? super T, Float> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
float floatValue = selector.invoke(it.next()).floatValue();
|
||
|
while (it.hasNext()) {
|
||
|
floatValue = Math.min(floatValue, selector.invoke(it.next()).floatValue());
|
||
|
}
|
||
|
return floatValue;
|
||
|
}
|
||
|
|
||
|
/* renamed from: minOf */
|
||
|
private static final <T, R extends Comparable<? super R>> R m6138minOf(Iterable<? extends T> iterable, Function1<? super T, ? extends R> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
R invoke = selector.invoke(it.next());
|
||
|
while (it.hasNext()) {
|
||
|
R invoke2 = selector.invoke(it.next());
|
||
|
if (invoke.compareTo(invoke2) > 0) {
|
||
|
invoke = invoke2;
|
||
|
}
|
||
|
}
|
||
|
return invoke;
|
||
|
}
|
||
|
|
||
|
/* renamed from: minOfOrNull */
|
||
|
private static final <T> Double m6139minOfOrNull(Iterable<? extends T> iterable, Function1<? super T, Double> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
double doubleValue = selector.invoke(it.next()).doubleValue();
|
||
|
while (it.hasNext()) {
|
||
|
doubleValue = Math.min(doubleValue, selector.invoke(it.next()).doubleValue());
|
||
|
}
|
||
|
return Double.valueOf(doubleValue);
|
||
|
}
|
||
|
|
||
|
/* renamed from: minOfOrNull */
|
||
|
private static final <T> Float m6140minOfOrNull(Iterable<? extends T> iterable, Function1<? super T, Float> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
float floatValue = selector.invoke(it.next()).floatValue();
|
||
|
while (it.hasNext()) {
|
||
|
floatValue = Math.min(floatValue, selector.invoke(it.next()).floatValue());
|
||
|
}
|
||
|
return Float.valueOf(floatValue);
|
||
|
}
|
||
|
|
||
|
private static final <T, R extends Comparable<? super R>> R minOfOrNull(Iterable<? extends T> iterable, Function1<? super T, ? extends R> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
R invoke = selector.invoke(it.next());
|
||
|
while (it.hasNext()) {
|
||
|
R invoke2 = selector.invoke(it.next());
|
||
|
if (invoke.compareTo(invoke2) > 0) {
|
||
|
invoke = invoke2;
|
||
|
}
|
||
|
}
|
||
|
return invoke;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
private static final <T, R> R minOfWith(Iterable<? extends T> iterable, Comparator<? super R> comparator, Function1<? super T, ? extends R> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(comparator, "comparator");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
Object obj = (R) selector.invoke((T) it.next());
|
||
|
while (it.hasNext()) {
|
||
|
Object obj2 = (R) selector.invoke((T) it.next());
|
||
|
if (comparator.compare(obj, obj2) > 0) {
|
||
|
obj = (R) obj2;
|
||
|
}
|
||
|
}
|
||
|
return (R) obj;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
private static final <T, R> R minOfWithOrNull(Iterable<? extends T> iterable, Comparator<? super R> comparator, Function1<? super T, ? extends R> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(comparator, "comparator");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
Object obj = (R) selector.invoke((T) it.next());
|
||
|
while (it.hasNext()) {
|
||
|
Object obj2 = (R) selector.invoke((T) it.next());
|
||
|
if (comparator.compare(obj, obj2) > 0) {
|
||
|
obj = (R) obj2;
|
||
|
}
|
||
|
}
|
||
|
return (R) obj;
|
||
|
}
|
||
|
|
||
|
/* renamed from: minOrNull */
|
||
|
public static final Double m6141minOrNull(Iterable<Double> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Double> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
double doubleValue = it.next().doubleValue();
|
||
|
while (it.hasNext()) {
|
||
|
doubleValue = Math.min(doubleValue, it.next().doubleValue());
|
||
|
}
|
||
|
return Double.valueOf(doubleValue);
|
||
|
}
|
||
|
|
||
|
/* renamed from: minOrNull */
|
||
|
public static final Float m6142minOrNull(Iterable<Float> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Float> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
float floatValue = it.next().floatValue();
|
||
|
while (it.hasNext()) {
|
||
|
floatValue = Math.min(floatValue, it.next().floatValue());
|
||
|
}
|
||
|
return Float.valueOf(floatValue);
|
||
|
}
|
||
|
|
||
|
public static final <T extends Comparable<? super T>> T minOrNull(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
T next = it.next();
|
||
|
while (it.hasNext()) {
|
||
|
T next2 = it.next();
|
||
|
if (next.compareTo(next2) > 0) {
|
||
|
next = next2;
|
||
|
}
|
||
|
}
|
||
|
return next;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public static final <T> T minWithOrThrow(Iterable<? extends T> iterable, Comparator<? super T> comparator) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(comparator, "comparator");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
Object obj = (T) it.next();
|
||
|
while (it.hasNext()) {
|
||
|
Object obj2 = (T) it.next();
|
||
|
if (comparator.compare(obj, obj2) > 0) {
|
||
|
obj = (T) obj2;
|
||
|
}
|
||
|
}
|
||
|
return (T) obj;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public static final <T> T minWithOrNull(Iterable<? extends T> iterable, Comparator<? super T> comparator) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(comparator, "comparator");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
Object obj = (T) it.next();
|
||
|
while (it.hasNext()) {
|
||
|
Object obj2 = (T) it.next();
|
||
|
if (comparator.compare(obj, obj2) > 0) {
|
||
|
obj = (T) obj2;
|
||
|
}
|
||
|
}
|
||
|
return (T) obj;
|
||
|
}
|
||
|
|
||
|
public static final <T> boolean none(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
return iterable instanceof Collection ? ((Collection) iterable).isEmpty() : !iterable.iterator().hasNext();
|
||
|
}
|
||
|
|
||
|
public static final <T> boolean none(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
if ((iterable instanceof Collection) && ((Collection) iterable).isEmpty()) {
|
||
|
return true;
|
||
|
}
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
if (predicate.invoke(it.next()).booleanValue()) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public static final <T, C extends Iterable<? extends T>> C onEach(C c, Function1<? super T, Unit> action) {
|
||
|
Intrinsics.checkNotNullParameter(c, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(action, "action");
|
||
|
Iterator<T> it = c.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
action.invoke(it.next());
|
||
|
}
|
||
|
return c;
|
||
|
}
|
||
|
|
||
|
public static final <S, T extends S> S reduce(Iterable<? extends T> iterable, Function2<? super S, ? super T, ? extends S> operation) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new UnsupportedOperationException("Empty collection can't be reduced.");
|
||
|
}
|
||
|
S next = it.next();
|
||
|
while (it.hasNext()) {
|
||
|
next = operation.invoke(next, it.next());
|
||
|
}
|
||
|
return next;
|
||
|
}
|
||
|
|
||
|
public static final <S, T extends S> S reduceIndexed(Iterable<? extends T> iterable, Function3<? super Integer, ? super S, ? super T, ? extends S> operation) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
throw new UnsupportedOperationException("Empty collection can't be reduced.");
|
||
|
}
|
||
|
S next = it.next();
|
||
|
int i = 1;
|
||
|
while (it.hasNext()) {
|
||
|
int i2 = i + 1;
|
||
|
if (i < 0) {
|
||
|
if (!PlatformImplementationsKt.apiVersionIsAtLeast(1, 3, 0)) {
|
||
|
throw new ArithmeticException("Index overflow has happened.");
|
||
|
}
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
next = operation.invoke(Integer.valueOf(i), next, it.next());
|
||
|
i = i2;
|
||
|
}
|
||
|
return next;
|
||
|
}
|
||
|
|
||
|
public static final <S, T extends S> S reduceIndexedOrNull(Iterable<? extends T> iterable, Function3<? super Integer, ? super S, ? super T, ? extends S> operation) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
S next = it.next();
|
||
|
int i = 1;
|
||
|
while (it.hasNext()) {
|
||
|
int i2 = i + 1;
|
||
|
if (i < 0) {
|
||
|
if (!PlatformImplementationsKt.apiVersionIsAtLeast(1, 3, 0)) {
|
||
|
throw new ArithmeticException("Index overflow has happened.");
|
||
|
}
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
next = operation.invoke(Integer.valueOf(i), next, it.next());
|
||
|
i = i2;
|
||
|
}
|
||
|
return next;
|
||
|
}
|
||
|
|
||
|
public static final <S, T extends S> S reduceOrNull(Iterable<? extends T> iterable, Function2<? super S, ? super T, ? extends S> operation) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return null;
|
||
|
}
|
||
|
S next = it.next();
|
||
|
while (it.hasNext()) {
|
||
|
next = operation.invoke(next, it.next());
|
||
|
}
|
||
|
return next;
|
||
|
}
|
||
|
|
||
|
public static final <S, T extends S> S reduceRight(List<? extends T> list, Function2<? super T, ? super S, ? extends S> operation) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
ListIterator<? extends T> listIterator = list.listIterator(list.size());
|
||
|
if (!listIterator.hasPrevious()) {
|
||
|
throw new UnsupportedOperationException("Empty list can't be reduced.");
|
||
|
}
|
||
|
S previous = listIterator.previous();
|
||
|
while (listIterator.hasPrevious()) {
|
||
|
previous = operation.invoke(listIterator.previous(), previous);
|
||
|
}
|
||
|
return previous;
|
||
|
}
|
||
|
|
||
|
public static final <S, T extends S> S reduceRightIndexed(List<? extends T> list, Function3<? super Integer, ? super T, ? super S, ? extends S> operation) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
ListIterator<? extends T> listIterator = list.listIterator(list.size());
|
||
|
if (!listIterator.hasPrevious()) {
|
||
|
throw new UnsupportedOperationException("Empty list can't be reduced.");
|
||
|
}
|
||
|
S previous = listIterator.previous();
|
||
|
while (listIterator.hasPrevious()) {
|
||
|
previous = operation.invoke(Integer.valueOf(listIterator.previousIndex()), listIterator.previous(), previous);
|
||
|
}
|
||
|
return previous;
|
||
|
}
|
||
|
|
||
|
public static final <S, T extends S> S reduceRightIndexedOrNull(List<? extends T> list, Function3<? super Integer, ? super T, ? super S, ? extends S> operation) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
ListIterator<? extends T> listIterator = list.listIterator(list.size());
|
||
|
if (!listIterator.hasPrevious()) {
|
||
|
return null;
|
||
|
}
|
||
|
S previous = listIterator.previous();
|
||
|
while (listIterator.hasPrevious()) {
|
||
|
previous = operation.invoke(Integer.valueOf(listIterator.previousIndex()), listIterator.previous(), previous);
|
||
|
}
|
||
|
return previous;
|
||
|
}
|
||
|
|
||
|
public static final <S, T extends S> S reduceRightOrNull(List<? extends T> list, Function2<? super T, ? super S, ? extends S> operation) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
ListIterator<? extends T> listIterator = list.listIterator(list.size());
|
||
|
if (!listIterator.hasPrevious()) {
|
||
|
return null;
|
||
|
}
|
||
|
S previous = listIterator.previous();
|
||
|
while (listIterator.hasPrevious()) {
|
||
|
previous = operation.invoke(listIterator.previous(), previous);
|
||
|
}
|
||
|
return previous;
|
||
|
}
|
||
|
|
||
|
public static final <T, R> List<R> runningFold(Iterable<? extends T> iterable, R r, Function2<? super R, ? super T, ? extends R> operation) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
int collectionSizeOrDefault = CollectionsKt.collectionSizeOrDefault(iterable, 9);
|
||
|
if (collectionSizeOrDefault == 0) {
|
||
|
return CollectionsKt.listOf(r);
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList(collectionSizeOrDefault + 1);
|
||
|
arrayList.add(r);
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
r = operation.invoke(r, it.next());
|
||
|
arrayList.add(r);
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T, R> List<R> runningFoldIndexed(Iterable<? extends T> iterable, R r, Function3<? super Integer, ? super R, ? super T, ? extends R> operation) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
int collectionSizeOrDefault = CollectionsKt.collectionSizeOrDefault(iterable, 9);
|
||
|
if (collectionSizeOrDefault == 0) {
|
||
|
return CollectionsKt.listOf(r);
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList(collectionSizeOrDefault + 1);
|
||
|
arrayList.add(r);
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
r = operation.invoke(Integer.valueOf(i), r, it.next());
|
||
|
arrayList.add(r);
|
||
|
i++;
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <S, T extends S> List<S> runningReduce(Iterable<? extends T> iterable, Function2<? super S, ? super T, ? extends S> operation) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return CollectionsKt.emptyList();
|
||
|
}
|
||
|
S next = it.next();
|
||
|
ArrayList arrayList = new ArrayList(CollectionsKt.collectionSizeOrDefault(iterable, 10));
|
||
|
arrayList.add(next);
|
||
|
while (it.hasNext()) {
|
||
|
next = operation.invoke(next, it.next());
|
||
|
arrayList.add(next);
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <S, T extends S> List<S> runningReduceIndexed(Iterable<? extends T> iterable, Function3<? super Integer, ? super S, ? super T, ? extends S> operation) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return CollectionsKt.emptyList();
|
||
|
}
|
||
|
S next = it.next();
|
||
|
ArrayList arrayList = new ArrayList(CollectionsKt.collectionSizeOrDefault(iterable, 10));
|
||
|
arrayList.add(next);
|
||
|
int i = 1;
|
||
|
while (it.hasNext()) {
|
||
|
next = operation.invoke(Integer.valueOf(i), next, it.next());
|
||
|
arrayList.add(next);
|
||
|
i++;
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
@Deprecated(message = "Use sumOf instead.", replaceWith = @ReplaceWith(expression = "this.sumOf(selector)", imports = {}))
|
||
|
@DeprecatedSinceKotlin(warningSince = "1.5")
|
||
|
public static final <T> int sumBy(Iterable<? extends T> iterable, Function1<? super T, Integer> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
i += selector.invoke(it.next()).intValue();
|
||
|
}
|
||
|
return i;
|
||
|
}
|
||
|
|
||
|
@Deprecated(message = "Use sumOf instead.", replaceWith = @ReplaceWith(expression = "this.sumOf(selector)", imports = {}))
|
||
|
@DeprecatedSinceKotlin(warningSince = "1.5")
|
||
|
public static final <T> double sumByDouble(Iterable<? extends T> iterable, Function1<? super T, Double> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
double d = BuildConfig.SENTRY_SAMPLE_RATE;
|
||
|
while (it.hasNext()) {
|
||
|
d += selector.invoke(it.next()).doubleValue();
|
||
|
}
|
||
|
return d;
|
||
|
}
|
||
|
|
||
|
private static final <T> double sumOfDouble(Iterable<? extends T> iterable, Function1<? super T, Double> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
double d = BuildConfig.SENTRY_SAMPLE_RATE;
|
||
|
while (it.hasNext()) {
|
||
|
d += selector.invoke(it.next()).doubleValue();
|
||
|
}
|
||
|
return d;
|
||
|
}
|
||
|
|
||
|
private static final <T> int sumOfInt(Iterable<? extends T> iterable, Function1<? super T, Integer> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
i += selector.invoke(it.next()).intValue();
|
||
|
}
|
||
|
return i;
|
||
|
}
|
||
|
|
||
|
private static final <T> long sumOfLong(Iterable<? extends T> iterable, Function1<? super T, Long> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
long j = 0;
|
||
|
while (it.hasNext()) {
|
||
|
j += selector.invoke(it.next()).longValue();
|
||
|
}
|
||
|
return j;
|
||
|
}
|
||
|
|
||
|
private static final <T> int sumOfUInt(Iterable<? extends T> iterable, Function1<? super T, UInt> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
int m5793constructorimpl = UInt.m5793constructorimpl(0);
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
m5793constructorimpl = UInt.m5793constructorimpl(m5793constructorimpl + selector.invoke(it.next()).getData());
|
||
|
}
|
||
|
return m5793constructorimpl;
|
||
|
}
|
||
|
|
||
|
private static final <T> long sumOfULong(Iterable<? extends T> iterable, Function1<? super T, ULong> selector) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(selector, "selector");
|
||
|
long m5872constructorimpl = ULong.m5872constructorimpl(0L);
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
m5872constructorimpl = ULong.m5872constructorimpl(m5872constructorimpl + selector.invoke(it.next()).getData());
|
||
|
}
|
||
|
return m5872constructorimpl;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public static final <T> Iterable<T> requireNoNulls(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
if (it.next() == null) {
|
||
|
throw new IllegalArgumentException("null element found in " + iterable + '.');
|
||
|
}
|
||
|
}
|
||
|
return iterable;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public static final <T> List<T> requireNoNulls(List<? extends T> list) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Iterator it = list.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
if (it.next() == null) {
|
||
|
throw new IllegalArgumentException("null element found in " + list + '.');
|
||
|
}
|
||
|
}
|
||
|
return list;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<List<T>> chunked(Iterable<? extends T> iterable, int i) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
return CollectionsKt.windowed(iterable, i, i, true);
|
||
|
}
|
||
|
|
||
|
public static final <T, R> List<R> chunked(Iterable<? extends T> iterable, int i, Function1<? super List<? extends T>, ? extends R> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
return CollectionsKt.windowed(iterable, i, i, true, transform);
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> minus(Iterable<? extends T> iterable, T t) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
ArrayList arrayList = new ArrayList(CollectionsKt.collectionSizeOrDefault(iterable, 10));
|
||
|
boolean z = false;
|
||
|
for (T t2 : iterable) {
|
||
|
boolean z2 = true;
|
||
|
if (!z && Intrinsics.areEqual(t2, t)) {
|
||
|
z = true;
|
||
|
z2 = false;
|
||
|
}
|
||
|
if (z2) {
|
||
|
arrayList.add(t2);
|
||
|
}
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> minus(Iterable<? extends T> iterable, T[] elements) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(elements, "elements");
|
||
|
if (elements.length == 0) {
|
||
|
return CollectionsKt.toList(iterable);
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
for (T t : iterable) {
|
||
|
if (!ArraysKt.contains(elements, t)) {
|
||
|
arrayList.add(t);
|
||
|
}
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> minus(Iterable<? extends T> iterable, Iterable<? extends T> elements) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(elements, "elements");
|
||
|
Collection convertToListIfNotCollection = CollectionsKt.convertToListIfNotCollection(elements);
|
||
|
if (convertToListIfNotCollection.isEmpty()) {
|
||
|
return CollectionsKt.toList(iterable);
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
for (T t : iterable) {
|
||
|
if (!convertToListIfNotCollection.contains(t)) {
|
||
|
arrayList.add(t);
|
||
|
}
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> minus(Iterable<? extends T> iterable, Sequence<? extends T> elements) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(elements, "elements");
|
||
|
List list = SequencesKt.toList(elements);
|
||
|
if (list.isEmpty()) {
|
||
|
return CollectionsKt.toList(iterable);
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
for (T t : iterable) {
|
||
|
if (!list.contains(t)) {
|
||
|
arrayList.add(t);
|
||
|
}
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
private static final <T> List<T> minusElement(Iterable<? extends T> iterable, T t) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
return CollectionsKt.minus(iterable, t);
|
||
|
}
|
||
|
|
||
|
public static final <T> Pair<List<T>, List<T>> partition(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
ArrayList arrayList2 = new ArrayList();
|
||
|
for (T t : iterable) {
|
||
|
if (predicate.invoke(t).booleanValue()) {
|
||
|
arrayList.add(t);
|
||
|
} else {
|
||
|
arrayList2.add(t);
|
||
|
}
|
||
|
}
|
||
|
return new Pair<>(arrayList, arrayList2);
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> plus(Iterable<? extends T> iterable, T t) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
if (iterable instanceof Collection) {
|
||
|
return CollectionsKt.plus((Collection) iterable, (Object) t);
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
CollectionsKt.addAll(arrayList, iterable);
|
||
|
arrayList.add(t);
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> plus(Collection<? extends T> collection, T t) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
ArrayList arrayList = new ArrayList(collection.size() + 1);
|
||
|
arrayList.addAll(collection);
|
||
|
arrayList.add(t);
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> plus(Iterable<? extends T> iterable, T[] elements) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(elements, "elements");
|
||
|
if (iterable instanceof Collection) {
|
||
|
return CollectionsKt.plus((Collection) iterable, (Object[]) elements);
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
ArrayList arrayList2 = arrayList;
|
||
|
CollectionsKt.addAll(arrayList2, iterable);
|
||
|
CollectionsKt.addAll(arrayList2, elements);
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> plus(Collection<? extends T> collection, T[] elements) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(elements, "elements");
|
||
|
ArrayList arrayList = new ArrayList(collection.size() + elements.length);
|
||
|
arrayList.addAll(collection);
|
||
|
CollectionsKt.addAll(arrayList, elements);
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> plus(Iterable<? extends T> iterable, Iterable<? extends T> elements) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(elements, "elements");
|
||
|
if (iterable instanceof Collection) {
|
||
|
return CollectionsKt.plus((Collection) iterable, (Iterable) elements);
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
ArrayList arrayList2 = arrayList;
|
||
|
CollectionsKt.addAll(arrayList2, iterable);
|
||
|
CollectionsKt.addAll(arrayList2, elements);
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> plus(Collection<? extends T> collection, Iterable<? extends T> elements) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(elements, "elements");
|
||
|
if (elements instanceof Collection) {
|
||
|
Collection collection2 = (Collection) elements;
|
||
|
ArrayList arrayList = new ArrayList(collection.size() + collection2.size());
|
||
|
arrayList.addAll(collection);
|
||
|
arrayList.addAll(collection2);
|
||
|
return arrayList;
|
||
|
}
|
||
|
ArrayList arrayList2 = new ArrayList(collection);
|
||
|
CollectionsKt.addAll(arrayList2, elements);
|
||
|
return arrayList2;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> plus(Iterable<? extends T> iterable, Sequence<? extends T> elements) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(elements, "elements");
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
ArrayList arrayList2 = arrayList;
|
||
|
CollectionsKt.addAll(arrayList2, iterable);
|
||
|
CollectionsKt.addAll(arrayList2, elements);
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<T> plus(Collection<? extends T> collection, Sequence<? extends T> elements) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(elements, "elements");
|
||
|
ArrayList arrayList = new ArrayList(collection.size() + 10);
|
||
|
arrayList.addAll(collection);
|
||
|
CollectionsKt.addAll(arrayList, elements);
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
private static final <T> List<T> plusElement(Iterable<? extends T> iterable, T t) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
return CollectionsKt.plus(iterable, t);
|
||
|
}
|
||
|
|
||
|
private static final <T> List<T> plusElement(Collection<? extends T> collection, T t) {
|
||
|
Intrinsics.checkNotNullParameter(collection, "<this>");
|
||
|
return CollectionsKt.plus((Collection) collection, (Object) t);
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ List windowed$default(Iterable iterable, int i, int i2, boolean z, int i3, Object obj) {
|
||
|
if ((i3 & 2) != 0) {
|
||
|
i2 = 1;
|
||
|
}
|
||
|
if ((i3 & 4) != 0) {
|
||
|
z = false;
|
||
|
}
|
||
|
return CollectionsKt.windowed(iterable, i, i2, z);
|
||
|
}
|
||
|
|
||
|
public static final <T> List<List<T>> windowed(Iterable<? extends T> iterable, int i, int i2, boolean z) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
SlidingWindowKt.checkWindowSizeStep(i, i2);
|
||
|
if ((iterable instanceof RandomAccess) && (iterable instanceof List)) {
|
||
|
List list = (List) iterable;
|
||
|
int size = list.size();
|
||
|
ArrayList arrayList = new ArrayList((size / i2) + (size % i2 == 0 ? 0 : 1));
|
||
|
int i3 = 0;
|
||
|
while (i3 >= 0 && i3 < size) {
|
||
|
int coerceAtMost = RangesKt.coerceAtMost(i, size - i3);
|
||
|
if (coerceAtMost < i && !z) {
|
||
|
break;
|
||
|
}
|
||
|
ArrayList arrayList2 = new ArrayList(coerceAtMost);
|
||
|
for (int i4 = 0; i4 < coerceAtMost; i4++) {
|
||
|
arrayList2.add(list.get(i4 + i3));
|
||
|
}
|
||
|
arrayList.add(arrayList2);
|
||
|
i3 += i2;
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
ArrayList arrayList3 = new ArrayList();
|
||
|
Iterator windowedIterator = SlidingWindowKt.windowedIterator(iterable.iterator(), i, i2, z, false);
|
||
|
while (windowedIterator.hasNext()) {
|
||
|
arrayList3.add((List) windowedIterator.next());
|
||
|
}
|
||
|
return arrayList3;
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ List windowed$default(Iterable iterable, int i, int i2, boolean z, Function1 function1, int i3, Object obj) {
|
||
|
if ((i3 & 2) != 0) {
|
||
|
i2 = 1;
|
||
|
}
|
||
|
if ((i3 & 4) != 0) {
|
||
|
z = false;
|
||
|
}
|
||
|
return CollectionsKt.windowed(iterable, i, i2, z, function1);
|
||
|
}
|
||
|
|
||
|
public static final <T, R> List<R> windowed(Iterable<? extends T> iterable, int i, int i2, boolean z, Function1<? super List<? extends T>, ? extends R> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
SlidingWindowKt.checkWindowSizeStep(i, i2);
|
||
|
if ((iterable instanceof RandomAccess) && (iterable instanceof List)) {
|
||
|
List list = (List) iterable;
|
||
|
int size = list.size();
|
||
|
int i3 = 0;
|
||
|
ArrayList arrayList = new ArrayList((size / i2) + (size % i2 == 0 ? 0 : 1));
|
||
|
MovingSubList movingSubList = new MovingSubList(list);
|
||
|
while (i3 >= 0 && i3 < size) {
|
||
|
int coerceAtMost = RangesKt.coerceAtMost(i, size - i3);
|
||
|
if (!z && coerceAtMost < i) {
|
||
|
break;
|
||
|
}
|
||
|
movingSubList.move(i3, coerceAtMost + i3);
|
||
|
arrayList.add(transform.invoke(movingSubList));
|
||
|
i3 += i2;
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
ArrayList arrayList2 = new ArrayList();
|
||
|
Iterator windowedIterator = SlidingWindowKt.windowedIterator(iterable.iterator(), i, i2, z, true);
|
||
|
while (windowedIterator.hasNext()) {
|
||
|
arrayList2.add(transform.invoke((List) windowedIterator.next()));
|
||
|
}
|
||
|
return arrayList2;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public static final <T, R, V> List<V> zip(Iterable<? extends T> iterable, R[] other, Function2<? super T, ? super R, ? extends V> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(other, "other");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
int length = other.length;
|
||
|
ArrayList arrayList = new ArrayList(Math.min(CollectionsKt.collectionSizeOrDefault(iterable, 10), length));
|
||
|
int i = 0;
|
||
|
for (T t : iterable) {
|
||
|
if (i >= length) {
|
||
|
break;
|
||
|
}
|
||
|
arrayList.add(transform.invoke(t, other[i]));
|
||
|
i++;
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T, R, V> List<V> zip(Iterable<? extends T> iterable, Iterable<? extends R> other, Function2<? super T, ? super R, ? extends V> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(other, "other");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
Iterator<? extends R> it2 = other.iterator();
|
||
|
ArrayList arrayList = new ArrayList(Math.min(CollectionsKt.collectionSizeOrDefault(iterable, 10), CollectionsKt.collectionSizeOrDefault(other, 10)));
|
||
|
while (it.hasNext() && it2.hasNext()) {
|
||
|
arrayList.add(transform.invoke(it.next(), it2.next()));
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T, R> List<R> zipWithNext(Iterable<? extends T> iterable, Function2<? super T, ? super T, ? extends R> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return CollectionsKt.emptyList();
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
DeviceControl$Companion$$ExternalSyntheticLambda4 next = it.next();
|
||
|
while (it.hasNext()) {
|
||
|
T next2 = it.next();
|
||
|
arrayList.add(transform.invoke(next, next2));
|
||
|
next = next2;
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T, A extends Appendable> A joinTo(Iterable<? extends T> iterable, A buffer, CharSequence separator, CharSequence prefix, CharSequence postfix, int i, CharSequence truncated, Function1<? super T, ? extends CharSequence> function1) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(buffer, "buffer");
|
||
|
Intrinsics.checkNotNullParameter(separator, "separator");
|
||
|
Intrinsics.checkNotNullParameter(prefix, "prefix");
|
||
|
Intrinsics.checkNotNullParameter(postfix, "postfix");
|
||
|
Intrinsics.checkNotNullParameter(truncated, "truncated");
|
||
|
buffer.append(prefix);
|
||
|
int i2 = 0;
|
||
|
for (T t : iterable) {
|
||
|
i2++;
|
||
|
if (i2 > 1) {
|
||
|
buffer.append(separator);
|
||
|
}
|
||
|
if (i >= 0 && i2 > i) {
|
||
|
break;
|
||
|
}
|
||
|
StringsKt.appendElement(buffer, t, function1);
|
||
|
}
|
||
|
if (i >= 0 && i2 > i) {
|
||
|
buffer.append(truncated);
|
||
|
}
|
||
|
buffer.append(postfix);
|
||
|
return buffer;
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ String joinToString$default(Iterable iterable, CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, int i, CharSequence charSequence4, Function1 function1, int i2, Object obj) {
|
||
|
if ((i2 & 1) != 0) {
|
||
|
}
|
||
|
if ((i2 & 2) != 0) {
|
||
|
}
|
||
|
CharSequence charSequence5 = charSequence2;
|
||
|
if ((i2 & 4) != 0) {
|
||
|
}
|
||
|
CharSequence charSequence6 = charSequence3;
|
||
|
if ((i2 & 8) != 0) {
|
||
|
i = -1;
|
||
|
}
|
||
|
int i3 = i;
|
||
|
if ((i2 & 16) != 0) {
|
||
|
}
|
||
|
CharSequence charSequence7 = charSequence4;
|
||
|
if ((i2 & 32) != 0) {
|
||
|
function1 = null;
|
||
|
}
|
||
|
return CollectionsKt.joinToString(iterable, charSequence, charSequence5, charSequence6, i3, charSequence7, function1);
|
||
|
}
|
||
|
|
||
|
public static final <T> String joinToString(Iterable<? extends T> iterable, CharSequence separator, CharSequence prefix, CharSequence postfix, int i, CharSequence truncated, Function1<? super T, ? extends CharSequence> function1) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(separator, "separator");
|
||
|
Intrinsics.checkNotNullParameter(prefix, "prefix");
|
||
|
Intrinsics.checkNotNullParameter(postfix, "postfix");
|
||
|
Intrinsics.checkNotNullParameter(truncated, "truncated");
|
||
|
String sb = ((StringBuilder) CollectionsKt.joinTo(iterable, new StringBuilder(), separator, prefix, postfix, i, truncated, function1)).toString();
|
||
|
Intrinsics.checkNotNullExpressionValue(sb, "toString(...)");
|
||
|
return sb;
|
||
|
}
|
||
|
|
||
|
public static final <T> Sequence<T> asSequence(final Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
return new Sequence<T>() { // from class: kotlin.collections.CollectionsKt___CollectionsKt$asSequence$$inlined$Sequence$1
|
||
|
@Override // kotlin.sequences.Sequence
|
||
|
public Iterator<T> iterator() {
|
||
|
return iterable.iterator();
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
public static final double averageOfByte(Iterable<Byte> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Byte> it = iterable.iterator();
|
||
|
double d = BuildConfig.SENTRY_SAMPLE_RATE;
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
d += it.next().byteValue();
|
||
|
i++;
|
||
|
if (i < 0) {
|
||
|
CollectionsKt.throwCountOverflow();
|
||
|
}
|
||
|
}
|
||
|
if (i == 0) {
|
||
|
return Double.NaN;
|
||
|
}
|
||
|
return d / i;
|
||
|
}
|
||
|
|
||
|
public static final double averageOfShort(Iterable<Short> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Short> it = iterable.iterator();
|
||
|
double d = BuildConfig.SENTRY_SAMPLE_RATE;
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
d += it.next().shortValue();
|
||
|
i++;
|
||
|
if (i < 0) {
|
||
|
CollectionsKt.throwCountOverflow();
|
||
|
}
|
||
|
}
|
||
|
if (i == 0) {
|
||
|
return Double.NaN;
|
||
|
}
|
||
|
return d / i;
|
||
|
}
|
||
|
|
||
|
public static final double averageOfInt(Iterable<Integer> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Integer> it = iterable.iterator();
|
||
|
double d = BuildConfig.SENTRY_SAMPLE_RATE;
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
d += it.next().intValue();
|
||
|
i++;
|
||
|
if (i < 0) {
|
||
|
CollectionsKt.throwCountOverflow();
|
||
|
}
|
||
|
}
|
||
|
if (i == 0) {
|
||
|
return Double.NaN;
|
||
|
}
|
||
|
return d / i;
|
||
|
}
|
||
|
|
||
|
public static final double averageOfLong(Iterable<Long> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Long> it = iterable.iterator();
|
||
|
double d = BuildConfig.SENTRY_SAMPLE_RATE;
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
d += it.next().longValue();
|
||
|
i++;
|
||
|
if (i < 0) {
|
||
|
CollectionsKt.throwCountOverflow();
|
||
|
}
|
||
|
}
|
||
|
if (i == 0) {
|
||
|
return Double.NaN;
|
||
|
}
|
||
|
return d / i;
|
||
|
}
|
||
|
|
||
|
public static final double averageOfFloat(Iterable<Float> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Float> it = iterable.iterator();
|
||
|
double d = BuildConfig.SENTRY_SAMPLE_RATE;
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
d += it.next().floatValue();
|
||
|
i++;
|
||
|
if (i < 0) {
|
||
|
CollectionsKt.throwCountOverflow();
|
||
|
}
|
||
|
}
|
||
|
if (i == 0) {
|
||
|
return Double.NaN;
|
||
|
}
|
||
|
return d / i;
|
||
|
}
|
||
|
|
||
|
public static final double averageOfDouble(Iterable<Double> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Double> it = iterable.iterator();
|
||
|
double d = BuildConfig.SENTRY_SAMPLE_RATE;
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
d += it.next().doubleValue();
|
||
|
i++;
|
||
|
if (i < 0) {
|
||
|
CollectionsKt.throwCountOverflow();
|
||
|
}
|
||
|
}
|
||
|
if (i == 0) {
|
||
|
return Double.NaN;
|
||
|
}
|
||
|
return d / i;
|
||
|
}
|
||
|
|
||
|
public static final int sumOfByte(Iterable<Byte> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Byte> it = iterable.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
i += it.next().byteValue();
|
||
|
}
|
||
|
return i;
|
||
|
}
|
||
|
|
||
|
public static final int sumOfShort(Iterable<Short> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Short> it = iterable.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
i += it.next().shortValue();
|
||
|
}
|
||
|
return i;
|
||
|
}
|
||
|
|
||
|
public static final int sumOfInt(Iterable<Integer> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Integer> it = iterable.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
i += it.next().intValue();
|
||
|
}
|
||
|
return i;
|
||
|
}
|
||
|
|
||
|
public static final long sumOfLong(Iterable<Long> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Long> it = iterable.iterator();
|
||
|
long j = 0;
|
||
|
while (it.hasNext()) {
|
||
|
j += it.next().longValue();
|
||
|
}
|
||
|
return j;
|
||
|
}
|
||
|
|
||
|
public static final float sumOfFloat(Iterable<Float> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Float> it = iterable.iterator();
|
||
|
float f = 0.0f;
|
||
|
while (it.hasNext()) {
|
||
|
f += it.next().floatValue();
|
||
|
}
|
||
|
return f;
|
||
|
}
|
||
|
|
||
|
public static final double sumOfDouble(Iterable<Double> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<Double> it = iterable.iterator();
|
||
|
double d = BuildConfig.SENTRY_SAMPLE_RATE;
|
||
|
while (it.hasNext()) {
|
||
|
d += it.next().doubleValue();
|
||
|
}
|
||
|
return d;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Type inference failed for: r0v4, types: [T, java.lang.Object] */
|
||
|
private static final <T> T find(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
for (T t : iterable) {
|
||
|
if (predicate.invoke(t).booleanValue()) {
|
||
|
return t;
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
/* JADX WARN: Type inference failed for: r1v1, types: [java.lang.Object] */
|
||
|
private static final <T> T findLast(Iterable<? extends T> iterable, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
T t = null;
|
||
|
for (T t2 : iterable) {
|
||
|
if (predicate.invoke(t2).booleanValue()) {
|
||
|
t = t2;
|
||
|
}
|
||
|
}
|
||
|
return t;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Type inference failed for: r0v5, types: [T, java.lang.Object] */
|
||
|
private static final <T> T findLast(List<? extends T> list, Function1<? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(list, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
ListIterator<? extends T> listIterator = list.listIterator(list.size());
|
||
|
while (listIterator.hasPrevious()) {
|
||
|
T previous = listIterator.previous();
|
||
|
if (predicate.invoke(previous).booleanValue()) {
|
||
|
return previous;
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
public static final <T, C extends Collection<? super T>> C filterIndexedTo(Iterable<? extends T> iterable, C destination, Function2<? super Integer, ? super T, Boolean> predicate) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Intrinsics.checkNotNullParameter(predicate, "predicate");
|
||
|
int i = 0;
|
||
|
for (T t : iterable) {
|
||
|
int i2 = i + 1;
|
||
|
if (i < 0) {
|
||
|
if (!PlatformImplementationsKt.apiVersionIsAtLeast(1, 3, 0)) {
|
||
|
throw new ArithmeticException("Index overflow has happened.");
|
||
|
}
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
if (predicate.invoke(Integer.valueOf(i), t).booleanValue()) {
|
||
|
destination.add(t);
|
||
|
}
|
||
|
i = i2;
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <T, R, C extends Collection<? super R>> C mapIndexedNotNullTo(Iterable<? extends T> iterable, C destination, Function2<? super Integer, ? super T, ? extends R> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
int i = 0;
|
||
|
for (T t : iterable) {
|
||
|
int i2 = i + 1;
|
||
|
if (i < 0) {
|
||
|
if (!PlatformImplementationsKt.apiVersionIsAtLeast(1, 3, 0)) {
|
||
|
throw new ArithmeticException("Index overflow has happened.");
|
||
|
}
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
R invoke = transform.invoke(Integer.valueOf(i), t);
|
||
|
if (invoke != null) {
|
||
|
destination.add(invoke);
|
||
|
}
|
||
|
i = i2;
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <T, R, C extends Collection<? super R>> C mapNotNullTo(Iterable<? extends T> iterable, C destination, Function1<? super T, ? extends R> transform) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(destination, "destination");
|
||
|
Intrinsics.checkNotNullParameter(transform, "transform");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
R invoke = transform.invoke(it.next());
|
||
|
if (invoke != null) {
|
||
|
destination.add(invoke);
|
||
|
}
|
||
|
}
|
||
|
return destination;
|
||
|
}
|
||
|
|
||
|
public static final <T, C extends Iterable<? extends T>> C onEachIndexed(C c, Function2<? super Integer, ? super T, Unit> action) {
|
||
|
Intrinsics.checkNotNullParameter(c, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(action, "action");
|
||
|
int i = 0;
|
||
|
for (T t : c) {
|
||
|
int i2 = i + 1;
|
||
|
if (i < 0) {
|
||
|
CollectionsKt.throwIndexOverflow();
|
||
|
}
|
||
|
action.invoke(Integer.valueOf(i), t);
|
||
|
i = i2;
|
||
|
}
|
||
|
return c;
|
||
|
}
|
||
|
|
||
|
public static final <T, R> List<R> scan(Iterable<? extends T> iterable, R r, Function2<? super R, ? super T, ? extends R> operation) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
int collectionSizeOrDefault = CollectionsKt.collectionSizeOrDefault(iterable, 9);
|
||
|
if (collectionSizeOrDefault == 0) {
|
||
|
return CollectionsKt.listOf(r);
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList(collectionSizeOrDefault + 1);
|
||
|
arrayList.add(r);
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
r = operation.invoke(r, it.next());
|
||
|
arrayList.add(r);
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T, R> List<R> scanIndexed(Iterable<? extends T> iterable, R r, Function3<? super Integer, ? super R, ? super T, ? extends R> operation) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(operation, "operation");
|
||
|
int collectionSizeOrDefault = CollectionsKt.collectionSizeOrDefault(iterable, 9);
|
||
|
if (collectionSizeOrDefault == 0) {
|
||
|
return CollectionsKt.listOf(r);
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList(collectionSizeOrDefault + 1);
|
||
|
arrayList.add(r);
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
r = operation.invoke(Integer.valueOf(i), r, it.next());
|
||
|
arrayList.add(r);
|
||
|
i++;
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T, R> List<Pair<T, R>> zip(Iterable<? extends T> iterable, R[] other) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(other, "other");
|
||
|
int length = other.length;
|
||
|
ArrayList arrayList = new ArrayList(Math.min(CollectionsKt.collectionSizeOrDefault(iterable, 10), length));
|
||
|
int i = 0;
|
||
|
for (T t : iterable) {
|
||
|
if (i >= length) {
|
||
|
break;
|
||
|
}
|
||
|
arrayList.add(TuplesKt.to(t, other[i]));
|
||
|
i++;
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T, R> List<Pair<T, R>> zip(Iterable<? extends T> iterable, Iterable<? extends R> other) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Intrinsics.checkNotNullParameter(other, "other");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
Iterator<? extends R> it2 = other.iterator();
|
||
|
ArrayList arrayList = new ArrayList(Math.min(CollectionsKt.collectionSizeOrDefault(iterable, 10), CollectionsKt.collectionSizeOrDefault(other, 10)));
|
||
|
while (it.hasNext() && it2.hasNext()) {
|
||
|
arrayList.add(TuplesKt.to(it.next(), it2.next()));
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static final <T> List<Pair<T, T>> zipWithNext(Iterable<? extends T> iterable) {
|
||
|
Intrinsics.checkNotNullParameter(iterable, "<this>");
|
||
|
Iterator<? extends T> it = iterable.iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
return CollectionsKt.emptyList();
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
T next = it.next();
|
||
|
while (it.hasNext()) {
|
||
|
T next2 = it.next();
|
||
|
arrayList.add(TuplesKt.to(next, next2));
|
||
|
next = next2;
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
}
|