package c.l;

import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

/* JADX INFO: Access modifiers changed from: package-private */
/* JADX INFO: compiled from: _Arrays.kt */
/* JADX INFO: loaded from: classes.dex */
public class f extends e {
    public static final <T> boolean f(T[] tArr, T t) {
        c.q.d.j.c(tArr, "$this$contains");
        return h(tArr, t) >= 0;
    }

    public static <T> int g(T[] tArr) {
        c.q.d.j.c(tArr, "$this$lastIndex");
        return tArr.length - 1;
    }

    public static final <T> int h(T[] tArr, T t) {
        c.q.d.j.c(tArr, "$this$indexOf");
        int i = 0;
        if (t == null) {
            int length = tArr.length;
            while (i < length) {
                if (tArr[i] == null) {
                    return i;
                }
                i++;
            }
            return -1;
        }
        int length2 = tArr.length;
        while (i < length2) {
            if (c.q.d.j.a(t, tArr[i])) {
                return i;
            }
            i++;
        }
        return -1;
    }

    public static char i(char[] cArr) {
        c.q.d.j.c(cArr, "$this$single");
        int length = cArr.length;
        if (length == 0) {
            throw new NoSuchElementException("Array is empty.");
        }
        if (length == 1) {
            return cArr[0];
        }
        throw new IllegalArgumentException("Array has more than one element.");
    }

    public static <T> T j(T[] tArr) {
        c.q.d.j.c(tArr, "$this$singleOrNull");
        if (tArr.length == 1) {
            return tArr[0];
        }
        return null;
    }

    public static <T> List<T> k(T[] tArr) {
        c.q.d.j.c(tArr, "$this$toList");
        int length = tArr.length;
        return length != 0 ? length != 1 ? l(tArr) : i.b(tArr[0]) : j.f();
    }

    public static <T> List<T> l(T[] tArr) {
        c.q.d.j.c(tArr, "$this$toMutableList");
        return new ArrayList(j.c(tArr));
    }
}
