package j;

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

/* JADX INFO: compiled from: UByteArray.kt */
/* JADX INFO: loaded from: classes.dex */
public final class y implements Collection<x>, j.p0.d.i0.a {
    private final byte[] b;

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

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

        public byte b() {
            int i2 = this.d;
            byte[] bArr = this.b;
            if (i2 >= bArr.length) {
                throw new NoSuchElementException(String.valueOf(this.d));
            }
            this.d = i2 + 1;
            byte b = bArr[i2];
            x.b(b);
            return b;
        }

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

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

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

    private /* synthetic */ y(byte[] bArr) {
        this.b = bArr;
    }

    public static final /* synthetic */ y b(byte[] bArr) {
        return new y(bArr);
    }

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

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

    public static boolean f(byte[] bArr, byte b) {
        return j.k0.j.n(bArr, b);
    }

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

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

    public static final byte i(byte[] bArr, int i2) {
        byte b = bArr[i2];
        x.b(b);
        return b;
    }

    public static int k(byte[] bArr) {
        return bArr.length;
    }

    public static int l(byte[] bArr) {
        return Arrays.hashCode(bArr);
    }

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

    public static Iterator<x> n(byte[] bArr) {
        return new a(bArr);
    }

    public static final void o(byte[] bArr, int i2, byte b) {
        bArr[i2] = b;
    }

    public static String p(byte[] bArr) {
        return "UByteArray(storage=" + Arrays.toString(bArr) + ')';
    }

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

    @Override // java.util.Collection
    public boolean addAll(Collection<? extends x> 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 x) {
            return e(((x) 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(byte b) {
        return f(this.b, b);
    }

    @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<x> 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 */ byte[] 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);
    }
}
