package j;

import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.NoSuchElementException;

/* JADX INFO: compiled from: UShortArray.kt */
/* JADX INFO: loaded from: classes.dex */
public final class f0 implements Collection<e0>, j.p0.d.i0.a {
    private final short[] b;

    /* JADX INFO: compiled from: UShortArray.kt */
    private static final class a implements Iterator<e0>, j.p0.d.i0.a {
        private final short[] b;
        private int d;

        public a(short[] sArr) {
            j.p0.d.r.f(sArr, "array");
            this.b = sArr;
        }

        public short b() {
            int i2 = this.d;
            short[] sArr = this.b;
            if (i2 >= sArr.length) {
                throw new NoSuchElementException(String.valueOf(this.d));
            }
            this.d = i2 + 1;
            short s = sArr[i2];
            e0.b(s);
            return s;
        }

        @Override // java.util.Iterator
        public boolean hasNext() {
            return this.d < this.b.length;
        }

        @Override // java.util.Iterator
        public /* bridge */ /* synthetic */ e0 next() {
            return e0.a(b());
        }

        @Override // java.util.Iterator
        public void remove() {
            throw new UnsupportedOperationException("Operation is not supported for read-only collection");
        }
    }

    private /* synthetic */ f0(short[] sArr) {
        this.b = sArr;
    }

    public static final /* synthetic */ f0 b(short[] sArr) {
        return new f0(sArr);
    }

    public static short[] c(int i2) {
        short[] sArr = new short[i2];
        d(sArr);
        return sArr;
    }

    public static short[] d(short[] sArr) {
        j.p0.d.r.f(sArr, "storage");
        return sArr;
    }

    public static boolean f(short[] sArr, short s) {
        return j.k0.j.r(sArr, s);
    }

    public static boolean g(short[] sArr, Collection<e0> collection) {
        j.p0.d.r.f(collection, "elements");
        if (!collection.isEmpty()) {
            for (Object obj : collection) {
                if (!((obj instanceof e0) && j.k0.j.r(sArr, ((e0) obj).f()))) {
                    return false;
                }
            }
        }
        return true;
    }

    public static boolean h(short[] sArr, Object obj) {
        return (obj instanceof f0) && j.p0.d.r.a(sArr, ((f0) obj).q());
    }

    public static final short i(short[] sArr, int i2) {
        short s = sArr[i2];
        e0.b(s);
        return s;
    }

    public static int k(short[] sArr) {
        return sArr.length;
    }

    public static int l(short[] sArr) {
        return Arrays.hashCode(sArr);
    }

    public static boolean m(short[] sArr) {
        return sArr.length == 0;
    }

    public static Iterator<e0> n(short[] sArr) {
        return new a(sArr);
    }

    public static final void o(short[] sArr, int i2, short s) {
        sArr[i2] = s;
    }

    public static String p(short[] sArr) {
        return "UShortArray(storage=" + Arrays.toString(sArr) + ')';
    }

    @Override // java.util.Collection
    public /* bridge */ /* synthetic */ boolean add(e0 e0Var) {
        throw new UnsupportedOperationException("Operation is not supported for read-only collection");
    }

    @Override // java.util.Collection
    public boolean addAll(Collection<? extends e0> collection) {
        throw new UnsupportedOperationException("Operation is not supported for read-only collection");
    }

    @Override // java.util.Collection
    public void clear() {
        throw new UnsupportedOperationException("Operation is not supported for read-only collection");
    }

    @Override // java.util.Collection
    public final /* bridge */ boolean contains(Object obj) {
        if (obj instanceof e0) {
            return e(((e0) obj).f());
        }
        return false;
    }

    @Override // java.util.Collection
    public boolean containsAll(Collection<? extends Object> collection) {
        j.p0.d.r.f(collection, "elements");
        return g(this.b, collection);
    }

    public boolean e(short s) {
        return f(this.b, s);
    }

    @Override // java.util.Collection
    public boolean equals(Object obj) {
        return h(this.b, obj);
    }

    @Override // java.util.Collection
    public int hashCode() {
        return l(this.b);
    }

    @Override // java.util.Collection
    public boolean isEmpty() {
        return m(this.b);
    }

    @Override // java.util.Collection, java.lang.Iterable
    public Iterator<e0> iterator() {
        return n(this.b);
    }

    @Override // java.util.Collection
    /* JADX INFO: renamed from: j, reason: merged with bridge method [inline-methods] */
    public int size() {
        return k(this.b);
    }

    public final /* synthetic */ short[] q() {
        return this.b;
    }

    @Override // java.util.Collection
    public boolean remove(Object obj) {
        throw new UnsupportedOperationException("Operation is not supported for read-only collection");
    }

    @Override // java.util.Collection
    public boolean removeAll(Collection<? extends Object> collection) {
        throw new UnsupportedOperationException("Operation is not supported for read-only collection");
    }

    @Override // java.util.Collection
    public boolean retainAll(Collection<? extends Object> collection) {
        throw new UnsupportedOperationException("Operation is not supported for read-only collection");
    }

    @Override // java.util.Collection
    public Object[] toArray() {
        return j.p0.d.i.a(this);
    }

    @Override // java.util.Collection
    public <T> T[] toArray(T[] tArr) {
        j.p0.d.r.f(tArr, "array");
        return (T[]) j.p0.d.i.b(this, tArr);
    }

    public String toString() {
        return p(this.b);
    }
}
