919 lines
35 KiB
Java
919 lines
35 KiB
Java
package d0.t;
|
|
|
|
import d0.d0.f;
|
|
import d0.g0.l;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Comparator;
|
|
import java.util.HashSet;
|
|
import java.util.Iterator;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.List;
|
|
import java.util.ListIterator;
|
|
import java.util.NoSuchElementException;
|
|
import java.util.Objects;
|
|
import java.util.RandomAccess;
|
|
import java.util.Set;
|
|
import kotlin.Pair;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.ranges.IntRange;
|
|
import kotlin.sequences.Sequence;
|
|
/* compiled from: _Collections.kt */
|
|
public class u extends t {
|
|
|
|
/* compiled from: Sequences.kt */
|
|
public static final class a implements Sequence<T> {
|
|
public final /* synthetic */ Iterable a;
|
|
|
|
public a(Iterable iterable) {
|
|
this.a = iterable;
|
|
}
|
|
|
|
@Override // kotlin.sequences.Sequence
|
|
public Iterator<T> iterator() {
|
|
return this.a.iterator();
|
|
}
|
|
}
|
|
|
|
/* compiled from: _Collections.kt */
|
|
public static final class b extends o implements Function1<Integer, T> {
|
|
public final /* synthetic */ int $index;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public b(int i) {
|
|
super(1);
|
|
this.$index = i;
|
|
}
|
|
|
|
public final T invoke(int i) {
|
|
throw new IndexOutOfBoundsException(c.d.b.a.a.w(c.d.b.a.a.L("Collection doesn't contain element at index "), this.$index, '.'));
|
|
}
|
|
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public /* bridge */ /* synthetic */ Object invoke(Integer num) {
|
|
return invoke(num.intValue());
|
|
}
|
|
}
|
|
|
|
/* compiled from: _Collections.kt */
|
|
public static final class c extends o implements Function0<Iterator<? extends T>> {
|
|
public final /* synthetic */ Iterable $this_withIndex;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public c(Iterable iterable) {
|
|
super(0);
|
|
this.$this_withIndex = iterable;
|
|
}
|
|
|
|
@Override // kotlin.jvm.functions.Function0
|
|
/* renamed from: invoke */
|
|
public final Iterator<T> mo1invoke() {
|
|
return this.$this_withIndex.iterator();
|
|
}
|
|
}
|
|
|
|
public static final <T> boolean all(Iterable<? extends T> iterable, Function1<? super T, Boolean> function1) {
|
|
m.checkNotNullParameter(iterable, "$this$all");
|
|
m.checkNotNullParameter(function1, "predicate");
|
|
if ((iterable instanceof Collection) && ((Collection) iterable).isEmpty()) {
|
|
return true;
|
|
}
|
|
Iterator<? extends T> it = iterable.iterator();
|
|
while (it.hasNext()) {
|
|
if (!function1.invoke((Object) it.next()).booleanValue()) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static final <T> Sequence<T> asSequence(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$asSequence");
|
|
return new a(iterable);
|
|
}
|
|
|
|
public static final double averageOfLong(Iterable<Long> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$average");
|
|
double d = 0.0d;
|
|
int i = 0;
|
|
for (Long l : iterable) {
|
|
d += (double) l.longValue();
|
|
i++;
|
|
if (i < 0) {
|
|
n.throwCountOverflow();
|
|
}
|
|
}
|
|
if (i == 0) {
|
|
return Double.NaN;
|
|
}
|
|
return d / ((double) i);
|
|
}
|
|
|
|
public static final <T> List<List<T>> chunked(Iterable<? extends T> iterable, int i) {
|
|
m.checkNotNullParameter(iterable, "$this$chunked");
|
|
return windowed(iterable, i, i, true);
|
|
}
|
|
|
|
public static final <T> boolean contains(Iterable<? extends T> iterable, T t) {
|
|
m.checkNotNullParameter(iterable, "$this$contains");
|
|
return iterable instanceof Collection ? ((Collection) iterable).contains(t) : indexOf(iterable, t) >= 0;
|
|
}
|
|
|
|
public static final <T> List<T> distinct(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$distinct");
|
|
return toList(toMutableSet(iterable));
|
|
}
|
|
|
|
public static final <T> List<T> drop(Iterable<? extends T> iterable, int i) {
|
|
ArrayList arrayList;
|
|
m.checkNotNullParameter(iterable, "$this$drop");
|
|
int i2 = 0;
|
|
if (!(i >= 0)) {
|
|
throw new IllegalArgumentException(c.d.b.a.a.l("Requested element count ", i, " is less than zero.").toString());
|
|
} else if (i == 0) {
|
|
return toList(iterable);
|
|
} else {
|
|
if (iterable instanceof Collection) {
|
|
Collection collection = (Collection) iterable;
|
|
int size = collection.size() - i;
|
|
if (size <= 0) {
|
|
return n.emptyList();
|
|
}
|
|
if (size == 1) {
|
|
return m.listOf(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();
|
|
}
|
|
for (Object obj : iterable) {
|
|
if (i2 >= i) {
|
|
arrayList.add(obj);
|
|
} else {
|
|
i2++;
|
|
}
|
|
}
|
|
return n.optimizeReadOnlyList(arrayList);
|
|
}
|
|
}
|
|
|
|
public static final <T> List<T> dropLast(List<? extends T> list, int i) {
|
|
m.checkNotNullParameter(list, "$this$dropLast");
|
|
if (i >= 0) {
|
|
return take(list, f.coerceAtLeast(list.size() - i, 0));
|
|
}
|
|
throw new IllegalArgumentException(c.d.b.a.a.l("Requested element count ", i, " is less than zero.").toString());
|
|
}
|
|
|
|
public static final <T> T elementAt(Iterable<? extends T> iterable, int i) {
|
|
m.checkNotNullParameter(iterable, "$this$elementAt");
|
|
return iterable instanceof List ? (T) ((List) iterable).get(i) : (T) elementAtOrElse(iterable, i, new b(i));
|
|
}
|
|
|
|
public static final <T> T elementAtOrElse(Iterable<? extends T> iterable, int i, Function1<? super Integer, ? extends T> function1) {
|
|
m.checkNotNullParameter(iterable, "$this$elementAtOrElse");
|
|
m.checkNotNullParameter(function1, "defaultValue");
|
|
if (iterable instanceof List) {
|
|
List list = (List) iterable;
|
|
return (i < 0 || i > n.getLastIndex(list)) ? (T) function1.invoke(Integer.valueOf(i)) : (T) list.get(i);
|
|
} else if (i < 0) {
|
|
return (T) function1.invoke(Integer.valueOf(i));
|
|
} else {
|
|
int i2 = 0;
|
|
for (T t : iterable) {
|
|
int i3 = i2 + 1;
|
|
if (i == i2) {
|
|
return t;
|
|
}
|
|
i2 = i3;
|
|
}
|
|
return (T) function1.invoke(Integer.valueOf(i));
|
|
}
|
|
}
|
|
|
|
public static final <T> List<T> filter(Iterable<? extends T> iterable, Function1<? super T, Boolean> function1) {
|
|
m.checkNotNullParameter(iterable, "$this$filter");
|
|
m.checkNotNullParameter(function1, "predicate");
|
|
ArrayList arrayList = new ArrayList();
|
|
Iterator<? extends T> it = iterable.iterator();
|
|
while (it.hasNext()) {
|
|
Object obj = (Object) it.next();
|
|
if (function1.invoke(obj).booleanValue()) {
|
|
arrayList.add(obj);
|
|
}
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
public static final <T> List<T> filterNotNull(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$filterNotNull");
|
|
return (List) filterNotNullTo(iterable, new ArrayList());
|
|
}
|
|
|
|
public static final <C extends Collection<? super T>, T> C filterNotNullTo(Iterable<? extends T> iterable, C c2) {
|
|
m.checkNotNullParameter(iterable, "$this$filterNotNullTo");
|
|
m.checkNotNullParameter(c2, "destination");
|
|
for (Object obj : iterable) {
|
|
if (obj != null) {
|
|
c2.add(obj);
|
|
}
|
|
}
|
|
return c2;
|
|
}
|
|
|
|
public static final <T> T first(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$first");
|
|
if (iterable instanceof List) {
|
|
return (T) first((List<? extends Object>) ((List) iterable));
|
|
}
|
|
Iterator<? extends T> it = iterable.iterator();
|
|
if (it.hasNext()) {
|
|
return (T) it.next();
|
|
}
|
|
throw new NoSuchElementException("Collection is empty.");
|
|
}
|
|
|
|
public static final <T> T first(List<? extends T> list) {
|
|
m.checkNotNullParameter(list, "$this$first");
|
|
if (!list.isEmpty()) {
|
|
return (T) list.get(0);
|
|
}
|
|
throw new NoSuchElementException("List is empty.");
|
|
}
|
|
|
|
public static final <T> T firstOrNull(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$firstOrNull");
|
|
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 null;
|
|
}
|
|
return (T) it.next();
|
|
}
|
|
|
|
public static final <T> T firstOrNull(List<? extends T> list) {
|
|
m.checkNotNullParameter(list, "$this$firstOrNull");
|
|
if (list.isEmpty()) {
|
|
return null;
|
|
}
|
|
return (T) list.get(0);
|
|
}
|
|
|
|
public static final <T> T getOrNull(List<? extends T> list, int i) {
|
|
m.checkNotNullParameter(list, "$this$getOrNull");
|
|
if (i < 0 || i > n.getLastIndex(list)) {
|
|
return null;
|
|
}
|
|
return (T) list.get(i);
|
|
}
|
|
|
|
public static final <T> int indexOf(Iterable<? extends T> iterable, T t) {
|
|
m.checkNotNullParameter(iterable, "$this$indexOf");
|
|
if (iterable instanceof List) {
|
|
return ((List) iterable).indexOf(t);
|
|
}
|
|
int i = 0;
|
|
for (Object obj : iterable) {
|
|
if (i < 0) {
|
|
n.throwIndexOverflow();
|
|
}
|
|
if (m.areEqual(t, obj)) {
|
|
return i;
|
|
}
|
|
i++;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public static final <T> Set<T> intersect(Iterable<? extends T> iterable, Iterable<? extends T> iterable2) {
|
|
m.checkNotNullParameter(iterable, "$this$intersect");
|
|
m.checkNotNullParameter(iterable2, "other");
|
|
Set<T> mutableSet = toMutableSet(iterable);
|
|
r.retainAll(mutableSet, iterable2);
|
|
return mutableSet;
|
|
}
|
|
|
|
public static final <T, A extends Appendable> A joinTo(Iterable<? extends T> iterable, A a2, CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, int i, CharSequence charSequence4, Function1<? super T, ? extends CharSequence> function1) {
|
|
m.checkNotNullParameter(iterable, "$this$joinTo");
|
|
m.checkNotNullParameter(a2, "buffer");
|
|
m.checkNotNullParameter(charSequence, "separator");
|
|
m.checkNotNullParameter(charSequence2, "prefix");
|
|
m.checkNotNullParameter(charSequence3, "postfix");
|
|
m.checkNotNullParameter(charSequence4, "truncated");
|
|
a2.append(charSequence2);
|
|
int i2 = 0;
|
|
for (Object obj : iterable) {
|
|
i2++;
|
|
if (i2 > 1) {
|
|
a2.append(charSequence);
|
|
}
|
|
if (i >= 0 && i2 > i) {
|
|
break;
|
|
}
|
|
l.appendElement(a2, obj, function1);
|
|
}
|
|
if (i >= 0 && i2 > i) {
|
|
a2.append(charSequence4);
|
|
}
|
|
a2.append(charSequence3);
|
|
return a2;
|
|
}
|
|
|
|
public static /* synthetic */ Appendable joinTo$default(Iterable iterable, Appendable appendable, CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, int i, CharSequence charSequence4, Function1 function1, int i2, Object obj) {
|
|
String str = (i2 & 2) != 0 ? ", " : charSequence;
|
|
CharSequence charSequence5 = "";
|
|
CharSequence charSequence6 = (i2 & 4) != 0 ? charSequence5 : charSequence2;
|
|
if ((i2 & 8) == 0) {
|
|
charSequence5 = charSequence3;
|
|
}
|
|
return joinTo(iterable, appendable, str, charSequence6, charSequence5, (i2 & 16) != 0 ? -1 : i, (i2 & 32) != 0 ? "..." : charSequence4, (i2 & 64) != 0 ? null : function1);
|
|
}
|
|
|
|
public static final <T> String joinToString(Iterable<? extends T> iterable, CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, int i, CharSequence charSequence4, Function1<? super T, ? extends CharSequence> function1) {
|
|
m.checkNotNullParameter(iterable, "$this$joinToString");
|
|
m.checkNotNullParameter(charSequence, "separator");
|
|
m.checkNotNullParameter(charSequence2, "prefix");
|
|
m.checkNotNullParameter(charSequence3, "postfix");
|
|
m.checkNotNullParameter(charSequence4, "truncated");
|
|
String sb = ((StringBuilder) joinTo(iterable, new StringBuilder(), charSequence, charSequence2, charSequence3, i, charSequence4, function1)).toString();
|
|
m.checkNotNullExpressionValue(sb, "joinTo(StringBuilder(), …ed, transform).toString()");
|
|
return sb;
|
|
}
|
|
|
|
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) {
|
|
charSequence = ", ";
|
|
}
|
|
CharSequence charSequence5 = "";
|
|
CharSequence charSequence6 = (i2 & 2) != 0 ? charSequence5 : charSequence2;
|
|
if ((i2 & 4) == 0) {
|
|
charSequence5 = charSequence3;
|
|
}
|
|
int i3 = (i2 & 8) != 0 ? -1 : i;
|
|
if ((i2 & 16) != 0) {
|
|
charSequence4 = "...";
|
|
}
|
|
if ((i2 & 32) != 0) {
|
|
function1 = null;
|
|
}
|
|
return joinToString(iterable, charSequence, charSequence6, charSequence5, i3, charSequence4, function1);
|
|
}
|
|
|
|
public static final <T> T last(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$last");
|
|
if (iterable instanceof List) {
|
|
return (T) last((List<? extends Object>) ((List) iterable));
|
|
}
|
|
Iterator<? extends T> it = iterable.iterator();
|
|
if (it.hasNext()) {
|
|
T t = (T) it.next();
|
|
while (it.hasNext()) {
|
|
t = (T) it.next();
|
|
}
|
|
return t;
|
|
}
|
|
throw new NoSuchElementException("Collection is empty.");
|
|
}
|
|
|
|
public static final <T> T last(List<? extends T> list) {
|
|
m.checkNotNullParameter(list, "$this$last");
|
|
if (!list.isEmpty()) {
|
|
return (T) list.get(n.getLastIndex(list));
|
|
}
|
|
throw new NoSuchElementException("List is empty.");
|
|
}
|
|
|
|
public static final <T> T lastOrNull(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$lastOrNull");
|
|
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 t = (T) it.next();
|
|
while (it.hasNext()) {
|
|
t = (T) it.next();
|
|
}
|
|
return t;
|
|
}
|
|
|
|
public static final <T> T lastOrNull(List<? extends T> list) {
|
|
m.checkNotNullParameter(list, "$this$lastOrNull");
|
|
if (list.isEmpty()) {
|
|
return null;
|
|
}
|
|
return (T) list.get(list.size() - 1);
|
|
}
|
|
|
|
public static final <T, R> List<R> map(Iterable<? extends T> iterable, Function1<? super T, ? extends R> function1) {
|
|
m.checkNotNullParameter(iterable, "$this$map");
|
|
m.checkNotNullParameter(function1, "transform");
|
|
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(iterable, 10));
|
|
Iterator<? extends T> it = iterable.iterator();
|
|
while (it.hasNext()) {
|
|
arrayList.add(function1.invoke((Object) it.next()));
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARNING: Unknown variable types count: 1 */
|
|
public static final <T extends Comparable<? super T>> T maxOrNull(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$maxOrNull");
|
|
Iterator<? extends T> it = iterable.iterator();
|
|
if (!it.hasNext()) {
|
|
return null;
|
|
}
|
|
T t = (T) ((Comparable) it.next());
|
|
while (it.hasNext()) {
|
|
?? r1 = (Comparable) it.next();
|
|
if (t.compareTo(r1) < 0) {
|
|
t = r1;
|
|
}
|
|
}
|
|
return t;
|
|
}
|
|
|
|
/* renamed from: maxOrNull reason: collision with other method in class */
|
|
public static final Float m92maxOrNull(Iterable<Float> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$maxOrNull");
|
|
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);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARNING: Unknown variable types count: 1 */
|
|
public static final <T extends Comparable<? super T>> T minOrNull(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$minOrNull");
|
|
Iterator<? extends T> it = iterable.iterator();
|
|
if (!it.hasNext()) {
|
|
return null;
|
|
}
|
|
T t = (T) ((Comparable) it.next());
|
|
while (it.hasNext()) {
|
|
?? r1 = (Comparable) it.next();
|
|
if (t.compareTo(r1) > 0) {
|
|
t = r1;
|
|
}
|
|
}
|
|
return t;
|
|
}
|
|
|
|
public static final <T> List<T> minus(Iterable<? extends T> iterable, Iterable<? extends T> iterable2) {
|
|
m.checkNotNullParameter(iterable, "$this$minus");
|
|
m.checkNotNullParameter(iterable2, "elements");
|
|
Collection convertToSetForSetOperationWith = o.convertToSetForSetOperationWith(iterable2, iterable);
|
|
if (convertToSetForSetOperationWith.isEmpty()) {
|
|
return toList(iterable);
|
|
}
|
|
ArrayList arrayList = new ArrayList();
|
|
for (Object obj : iterable) {
|
|
if (!convertToSetForSetOperationWith.contains(obj)) {
|
|
arrayList.add(obj);
|
|
}
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
public static final <T> List<T> minus(Iterable<? extends T> iterable, T t) {
|
|
m.checkNotNullParameter(iterable, "$this$minus");
|
|
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(iterable, 10));
|
|
boolean z2 = false;
|
|
for (Object obj : iterable) {
|
|
boolean z3 = true;
|
|
if (!z2 && m.areEqual(obj, t)) {
|
|
z2 = true;
|
|
z3 = false;
|
|
}
|
|
if (z3) {
|
|
arrayList.add(obj);
|
|
}
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
public static final <T> List<T> plus(Iterable<? extends T> iterable, Iterable<? extends T> iterable2) {
|
|
m.checkNotNullParameter(iterable, "$this$plus");
|
|
m.checkNotNullParameter(iterable2, "elements");
|
|
if (iterable instanceof Collection) {
|
|
return plus((Collection) iterable, (Iterable) iterable2);
|
|
}
|
|
ArrayList arrayList = new ArrayList();
|
|
r.addAll(arrayList, iterable);
|
|
r.addAll(arrayList, iterable2);
|
|
return arrayList;
|
|
}
|
|
|
|
public static final <T> List<T> plus(Iterable<? extends T> iterable, T t) {
|
|
m.checkNotNullParameter(iterable, "$this$plus");
|
|
if (iterable instanceof Collection) {
|
|
return plus((Collection) iterable, (Object) t);
|
|
}
|
|
ArrayList arrayList = new ArrayList();
|
|
r.addAll(arrayList, iterable);
|
|
arrayList.add(t);
|
|
return arrayList;
|
|
}
|
|
|
|
public static final <T> List<T> plus(Collection<? extends T> collection, Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(collection, "$this$plus");
|
|
m.checkNotNullParameter(iterable, "elements");
|
|
if (iterable instanceof Collection) {
|
|
Collection collection2 = (Collection) iterable;
|
|
ArrayList arrayList = new ArrayList(collection2.size() + collection.size());
|
|
arrayList.addAll(collection);
|
|
arrayList.addAll(collection2);
|
|
return arrayList;
|
|
}
|
|
ArrayList arrayList2 = new ArrayList(collection);
|
|
r.addAll(arrayList2, iterable);
|
|
return arrayList2;
|
|
}
|
|
|
|
public static final <T> List<T> plus(Collection<? extends T> collection, T t) {
|
|
m.checkNotNullParameter(collection, "$this$plus");
|
|
ArrayList arrayList = new ArrayList(collection.size() + 1);
|
|
arrayList.addAll(collection);
|
|
arrayList.add(t);
|
|
return arrayList;
|
|
}
|
|
|
|
public static final <T> List<T> plus(Collection<? extends T> collection, Sequence<? extends T> sequence) {
|
|
m.checkNotNullParameter(collection, "$this$plus");
|
|
m.checkNotNullParameter(sequence, "elements");
|
|
ArrayList arrayList = new ArrayList(collection.size() + 10);
|
|
arrayList.addAll(collection);
|
|
r.addAll(arrayList, sequence);
|
|
return arrayList;
|
|
}
|
|
|
|
public static final <T> T random(Collection<? extends T> collection, d0.c0.c cVar) {
|
|
m.checkNotNullParameter(collection, "$this$random");
|
|
m.checkNotNullParameter(cVar, "random");
|
|
if (!collection.isEmpty()) {
|
|
return (T) elementAt(collection, cVar.nextInt(collection.size()));
|
|
}
|
|
throw new NoSuchElementException("Collection is empty.");
|
|
}
|
|
|
|
public static final <T> List<T> reversed(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$reversed");
|
|
if ((iterable instanceof Collection) && ((Collection) iterable).size() <= 1) {
|
|
return toList(iterable);
|
|
}
|
|
List<T> mutableList = toMutableList(iterable);
|
|
t.reverse(mutableList);
|
|
return mutableList;
|
|
}
|
|
|
|
public static final <T> T single(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$single");
|
|
if (iterable instanceof List) {
|
|
return (T) single((List<? extends Object>) ((List) iterable));
|
|
}
|
|
Iterator<? extends T> it = iterable.iterator();
|
|
if (it.hasNext()) {
|
|
T t = (T) it.next();
|
|
if (!it.hasNext()) {
|
|
return t;
|
|
}
|
|
throw new IllegalArgumentException("Collection has more than one element.");
|
|
}
|
|
throw new NoSuchElementException("Collection is empty.");
|
|
}
|
|
|
|
public static final <T> T single(List<? extends T> list) {
|
|
m.checkNotNullParameter(list, "$this$single");
|
|
int size = list.size();
|
|
if (size == 0) {
|
|
throw new NoSuchElementException("List is empty.");
|
|
} else if (size == 1) {
|
|
return (T) list.get(0);
|
|
} else {
|
|
throw new IllegalArgumentException("List has more than one element.");
|
|
}
|
|
}
|
|
|
|
public static final <T> T singleOrNull(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$singleOrNull");
|
|
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 t = (T) it.next();
|
|
if (it.hasNext()) {
|
|
return null;
|
|
}
|
|
return t;
|
|
}
|
|
|
|
public static final <T> T singleOrNull(List<? extends T> list) {
|
|
m.checkNotNullParameter(list, "$this$singleOrNull");
|
|
if (list.size() == 1) {
|
|
return (T) list.get(0);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static final <T> List<T> slice(List<? extends T> list, IntRange intRange) {
|
|
m.checkNotNullParameter(list, "$this$slice");
|
|
m.checkNotNullParameter(intRange, "indices");
|
|
return intRange.isEmpty() ? n.emptyList() : toList(list.subList(intRange.getStart().intValue(), intRange.getEndInclusive().intValue() + 1));
|
|
}
|
|
|
|
public static final <T extends Comparable<? super T>> List<T> sorted(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$sorted");
|
|
if (iterable instanceof Collection) {
|
|
Collection collection = (Collection) iterable;
|
|
if (collection.size() <= 1) {
|
|
return toList(iterable);
|
|
}
|
|
Object[] array = collection.toArray(new Comparable[0]);
|
|
Objects.requireNonNull(array, "null cannot be cast to non-null type kotlin.Array<T>");
|
|
Comparable[] comparableArr = (Comparable[]) array;
|
|
j.sort(comparableArr);
|
|
return j.asList(comparableArr);
|
|
}
|
|
List<T> mutableList = toMutableList(iterable);
|
|
q.sort(mutableList);
|
|
return mutableList;
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v4, resolved type: java.util.Collection */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static final <T> List<T> sortedWith(Iterable<? extends T> iterable, Comparator<? super T> comparator) {
|
|
m.checkNotNullParameter(iterable, "$this$sortedWith");
|
|
m.checkNotNullParameter(comparator, "comparator");
|
|
if (iterable instanceof Collection) {
|
|
Collection collection = (Collection) iterable;
|
|
if (collection.size() <= 1) {
|
|
return toList(iterable);
|
|
}
|
|
Object[] array = collection.toArray(new Object[0]);
|
|
Objects.requireNonNull(array, "null cannot be cast to non-null type kotlin.Array<T>");
|
|
j.sortWith(array, comparator);
|
|
return j.asList(array);
|
|
}
|
|
List<T> mutableList = toMutableList(iterable);
|
|
q.sortWith(mutableList, comparator);
|
|
return mutableList;
|
|
}
|
|
|
|
public static final float sumOfFloat(Iterable<Float> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$sum");
|
|
float f = 0.0f;
|
|
for (Float f2 : iterable) {
|
|
f += f2.floatValue();
|
|
}
|
|
return f;
|
|
}
|
|
|
|
public static final int sumOfInt(Iterable<Integer> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$sum");
|
|
int i = 0;
|
|
for (Integer num : iterable) {
|
|
i += num.intValue();
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public static final long sumOfLong(Iterable<Long> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$sum");
|
|
long j = 0;
|
|
for (Long l : iterable) {
|
|
j += l.longValue();
|
|
}
|
|
return j;
|
|
}
|
|
|
|
public static final <T> List<T> take(Iterable<? extends T> iterable, int i) {
|
|
m.checkNotNullParameter(iterable, "$this$take");
|
|
int i2 = 0;
|
|
if (!(i >= 0)) {
|
|
throw new IllegalArgumentException(c.d.b.a.a.l("Requested element count ", i, " is less than zero.").toString());
|
|
} else if (i == 0) {
|
|
return n.emptyList();
|
|
} else {
|
|
if (iterable instanceof Collection) {
|
|
if (i >= ((Collection) iterable).size()) {
|
|
return toList(iterable);
|
|
}
|
|
if (i == 1) {
|
|
return m.listOf(first(iterable));
|
|
}
|
|
}
|
|
ArrayList arrayList = new ArrayList(i);
|
|
Iterator<? extends T> it = iterable.iterator();
|
|
while (it.hasNext()) {
|
|
arrayList.add(it.next());
|
|
i2++;
|
|
if (i2 == i) {
|
|
break;
|
|
}
|
|
}
|
|
return n.optimizeReadOnlyList(arrayList);
|
|
}
|
|
}
|
|
|
|
public static final <T> List<T> takeLast(List<? extends T> list, int i) {
|
|
m.checkNotNullParameter(list, "$this$takeLast");
|
|
if (!(i >= 0)) {
|
|
throw new IllegalArgumentException(c.d.b.a.a.l("Requested element count ", i, " is less than zero.").toString());
|
|
} else if (i == 0) {
|
|
return n.emptyList();
|
|
} else {
|
|
int size = list.size();
|
|
if (i >= size) {
|
|
return toList(list);
|
|
}
|
|
if (i == 1) {
|
|
return m.listOf(last((List<? extends Object>) 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, C extends Collection<? super T>> C toCollection(Iterable<? extends T> iterable, C c2) {
|
|
m.checkNotNullParameter(iterable, "$this$toCollection");
|
|
m.checkNotNullParameter(c2, "destination");
|
|
Iterator<? extends T> it = iterable.iterator();
|
|
while (it.hasNext()) {
|
|
c2.add(it.next());
|
|
}
|
|
return c2;
|
|
}
|
|
|
|
public static final <T> HashSet<T> toHashSet(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$toHashSet");
|
|
return (HashSet) toCollection(iterable, new HashSet(g0.mapCapacity(o.collectionSizeOrDefault(iterable, 12))));
|
|
}
|
|
|
|
public static final int[] toIntArray(Collection<Integer> collection) {
|
|
m.checkNotNullParameter(collection, "$this$toIntArray");
|
|
int[] iArr = new int[collection.size()];
|
|
int i = 0;
|
|
for (Integer num : collection) {
|
|
iArr[i] = num.intValue();
|
|
i++;
|
|
}
|
|
return iArr;
|
|
}
|
|
|
|
public static final <T> List<T> toList(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$toList");
|
|
if (!(iterable instanceof Collection)) {
|
|
return n.optimizeReadOnlyList(toMutableList(iterable));
|
|
}
|
|
Collection collection = (Collection) iterable;
|
|
int size = collection.size();
|
|
if (size == 0) {
|
|
return n.emptyList();
|
|
}
|
|
if (size != 1) {
|
|
return toMutableList(collection);
|
|
}
|
|
return m.listOf(iterable instanceof List ? ((List) iterable).get(0) : iterable.iterator().next());
|
|
}
|
|
|
|
public static final <T> List<T> toMutableList(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$toMutableList");
|
|
return iterable instanceof Collection ? toMutableList((Collection) iterable) : (List) toCollection(iterable, new ArrayList());
|
|
}
|
|
|
|
public static final <T> List<T> toMutableList(Collection<? extends T> collection) {
|
|
m.checkNotNullParameter(collection, "$this$toMutableList");
|
|
return new ArrayList(collection);
|
|
}
|
|
|
|
public static final <T> Set<T> toMutableSet(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$toMutableSet");
|
|
return iterable instanceof Collection ? new LinkedHashSet((Collection) iterable) : (Set) toCollection(iterable, new LinkedHashSet());
|
|
}
|
|
|
|
public static final <T> Set<T> toSet(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$toSet");
|
|
if (!(iterable instanceof Collection)) {
|
|
return n0.optimizeReadOnlySet((Set) toCollection(iterable, new LinkedHashSet()));
|
|
}
|
|
Collection collection = (Collection) iterable;
|
|
int size = collection.size();
|
|
if (size == 0) {
|
|
return n0.emptySet();
|
|
}
|
|
if (size != 1) {
|
|
return (Set) toCollection(iterable, new LinkedHashSet(g0.mapCapacity(collection.size())));
|
|
}
|
|
return m0.setOf(iterable instanceof List ? ((List) iterable).get(0) : iterable.iterator().next());
|
|
}
|
|
|
|
public static final <T> Set<T> union(Iterable<? extends T> iterable, Iterable<? extends T> iterable2) {
|
|
m.checkNotNullParameter(iterable, "$this$union");
|
|
m.checkNotNullParameter(iterable2, "other");
|
|
Set<T> mutableSet = toMutableSet(iterable);
|
|
r.addAll(mutableSet, iterable2);
|
|
return mutableSet;
|
|
}
|
|
|
|
public static final <T> List<List<T>> windowed(Iterable<? extends T> iterable, int i, int i2, boolean z2) {
|
|
m.checkNotNullParameter(iterable, "$this$windowed");
|
|
p0.checkWindowSizeStep(i, i2);
|
|
if (!(iterable instanceof RandomAccess) || !(iterable instanceof List)) {
|
|
ArrayList arrayList = new ArrayList();
|
|
Iterator windowedIterator = p0.windowedIterator(iterable.iterator(), i, i2, z2, false);
|
|
while (windowedIterator.hasNext()) {
|
|
arrayList.add((List) windowedIterator.next());
|
|
}
|
|
return arrayList;
|
|
}
|
|
List list = (List) iterable;
|
|
int size = list.size();
|
|
ArrayList arrayList2 = new ArrayList((size / i2) + (size % i2 == 0 ? 0 : 1));
|
|
int i3 = 0;
|
|
while (i3 >= 0 && size > i3) {
|
|
int coerceAtMost = f.coerceAtMost(i, size - i3);
|
|
if (coerceAtMost < i && !z2) {
|
|
break;
|
|
}
|
|
ArrayList arrayList3 = new ArrayList(coerceAtMost);
|
|
for (int i4 = 0; i4 < coerceAtMost; i4++) {
|
|
arrayList3.add(list.get(i4 + i3));
|
|
}
|
|
arrayList2.add(arrayList3);
|
|
i3 += i2;
|
|
}
|
|
return arrayList2;
|
|
}
|
|
|
|
public static final <T> Iterable<z<T>> withIndex(Iterable<? extends T> iterable) {
|
|
m.checkNotNullParameter(iterable, "$this$withIndex");
|
|
return new a0(new c(iterable));
|
|
}
|
|
|
|
public static final <T, R> List<Pair<T, R>> zip(Iterable<? extends T> iterable, Iterable<? extends R> iterable2) {
|
|
m.checkNotNullParameter(iterable, "$this$zip");
|
|
m.checkNotNullParameter(iterable2, "other");
|
|
Iterator<? extends T> it = iterable.iterator();
|
|
Iterator<? extends R> it2 = iterable2.iterator();
|
|
ArrayList arrayList = new ArrayList(Math.min(o.collectionSizeOrDefault(iterable, 10), o.collectionSizeOrDefault(iterable2, 10)));
|
|
while (it.hasNext() && it2.hasNext()) {
|
|
arrayList.add(d0.o.to(it.next(), it2.next()));
|
|
}
|
|
return arrayList;
|
|
}
|
|
}
|