package com.google.common.collect;

import com.google.common.collect.p;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public final class j0 extends p {

    /* renamed from: w, reason: collision with root package name */
    static final p f14251w = new j0(null, new Object[0], 0);

    /* renamed from: t, reason: collision with root package name */
    private final transient Object f14252t;

    /* renamed from: u, reason: collision with root package name */
    final transient Object[] f14253u;

    /* renamed from: v, reason: collision with root package name */
    private final transient int f14254v;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes3.dex */
    public static class a extends r {

        /* renamed from: r, reason: collision with root package name */
        private final transient p f14255r;

        /* renamed from: s, reason: collision with root package name */
        private final transient Object[] f14256s;

        /* renamed from: t, reason: collision with root package name */
        private final transient int f14257t;

        /* renamed from: u, reason: collision with root package name */
        private final transient int f14258u;

        /* renamed from: com.google.common.collect.j0$a$a, reason: collision with other inner class name */
        /* loaded from: classes3.dex */
        class C0320a extends o {
            C0320a() {
            }

            @Override // java.util.List
            /* renamed from: F, reason: merged with bridge method [inline-methods] */
            public Map.Entry get(int i10) {
                ck.j.g(i10, a.this.f14258u);
                int i11 = i10 * 2;
                Object obj = a.this.f14256s[a.this.f14257t + i11];
                Objects.requireNonNull(obj);
                Object obj2 = a.this.f14256s[i11 + (a.this.f14257t ^ 1)];
                Objects.requireNonNull(obj2);
                return new AbstractMap.SimpleImmutableEntry(obj, obj2);
            }

            @Override // com.google.common.collect.n
            public boolean l() {
                return true;
            }

            @Override // java.util.AbstractCollection, java.util.Collection, java.util.List
            public int size() {
                return a.this.f14258u;
            }
        }

        a(p pVar, Object[] objArr, int i10, int i11) {
            this.f14255r = pVar;
            this.f14256s = objArr;
            this.f14257t = i10;
            this.f14258u = i11;
        }

        @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
        /* renamed from: F, reason: merged with bridge method [inline-methods] */
        public r0 iterator() {
            return m().iterator();
        }

        @Override // com.google.common.collect.n, java.util.AbstractCollection, java.util.Collection, java.util.Set
        public boolean contains(Object obj) {
            if (!(obj instanceof Map.Entry)) {
                return false;
            }
            Map.Entry entry = (Map.Entry) obj;
            Object key = entry.getKey();
            Object value = entry.getValue();
            return value != null && value.equals(this.f14255r.get(key));
        }

        @Override // com.google.common.collect.n
        int e(Object[] objArr, int i10) {
            return m().e(objArr, i10);
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // com.google.common.collect.n
        public boolean l() {
            return true;
        }

        @Override // com.google.common.collect.r
        o r() {
            return new C0320a();
        }

        @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
        public int size() {
            return this.f14258u;
        }
    }

    /* loaded from: classes3.dex */
    static final class b extends r {

        /* renamed from: r, reason: collision with root package name */
        private final transient p f14260r;

        /* renamed from: s, reason: collision with root package name */
        private final transient o f14261s;

        b(p pVar, o oVar) {
            this.f14260r = pVar;
            this.f14261s = oVar;
        }

        @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
        /* renamed from: C, reason: merged with bridge method [inline-methods] */
        public r0 iterator() {
            return m().iterator();
        }

        @Override // com.google.common.collect.n, java.util.AbstractCollection, java.util.Collection, java.util.Set
        public boolean contains(Object obj) {
            return this.f14260r.get(obj) != null;
        }

        @Override // com.google.common.collect.n
        int e(Object[] objArr, int i10) {
            return m().e(objArr, i10);
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // com.google.common.collect.n
        public boolean l() {
            return true;
        }

        @Override // com.google.common.collect.r
        public o m() {
            return this.f14261s;
        }

        @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
        public int size() {
            return this.f14260r.size();
        }
    }

    /* loaded from: classes3.dex */
    static final class c extends o {

        /* renamed from: r, reason: collision with root package name */
        private final transient Object[] f14262r;

        /* renamed from: s, reason: collision with root package name */
        private final transient int f14263s;

        /* renamed from: t, reason: collision with root package name */
        private final transient int f14264t;

        c(Object[] objArr, int i10, int i11) {
            this.f14262r = objArr;
            this.f14263s = i10;
            this.f14264t = i11;
        }

        @Override // java.util.List
        public Object get(int i10) {
            ck.j.g(i10, this.f14264t);
            Object obj = this.f14262r[(i10 * 2) + this.f14263s];
            Objects.requireNonNull(obj);
            return obj;
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        @Override // com.google.common.collect.n
        public boolean l() {
            return true;
        }

        @Override // java.util.AbstractCollection, java.util.Collection, java.util.List
        public int size() {
            return this.f14264t;
        }
    }

    private j0(Object obj, Object[] objArr, int i10) {
        this.f14252t = obj;
        this.f14253u = objArr;
        this.f14254v = i10;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static j0 j(int i10, Object[] objArr, p.a aVar) {
        if (i10 == 0) {
            return (j0) f14251w;
        }
        if (i10 == 1) {
            Object obj = objArr[0];
            Objects.requireNonNull(obj);
            Object obj2 = objArr[1];
            Objects.requireNonNull(obj2);
            g.a(obj, obj2);
            return new j0(null, objArr, 1);
        }
        ck.j.k(i10, objArr.length >> 1);
        Object m10 = m(objArr, i10, r.n(i10), 0);
        if (m10 instanceof Object[]) {
            Object[] objArr2 = (Object[]) m10;
            p.a.C0322a c0322a = (p.a.C0322a) objArr2[2];
            if (aVar == null) {
                throw c0322a.a();
            }
            aVar.f14300e = c0322a;
            Object obj3 = objArr2[0];
            int intValue = ((Integer) objArr2[1]).intValue();
            objArr = Arrays.copyOf(objArr, intValue * 2);
            m10 = obj3;
            i10 = intValue;
        }
        return new j0(m10, objArr, i10);
    }

    private static Object m(Object[] objArr, int i10, int i11, int i12) {
        p.a.C0322a c0322a = null;
        if (i10 == 1) {
            Object obj = objArr[i12];
            Objects.requireNonNull(obj);
            Object obj2 = objArr[i12 ^ 1];
            Objects.requireNonNull(obj2);
            g.a(obj, obj2);
            return null;
        }
        int i13 = i11 - 1;
        int i14 = 0;
        if (i11 <= 128) {
            byte[] bArr = new byte[i11];
            Arrays.fill(bArr, (byte) -1);
            int i15 = 0;
            while (i14 < i10) {
                int i16 = (i14 * 2) + i12;
                int i17 = (i15 * 2) + i12;
                Object obj3 = objArr[i16];
                Objects.requireNonNull(obj3);
                Object obj4 = objArr[i16 ^ 1];
                Objects.requireNonNull(obj4);
                g.a(obj3, obj4);
                int b10 = m.b(obj3.hashCode());
                while (true) {
                    int i18 = b10 & i13;
                    int i19 = bArr[i18] & 255;
                    if (i19 == 255) {
                        bArr[i18] = (byte) i17;
                        if (i15 < i14) {
                            objArr[i17] = obj3;
                            objArr[i17 ^ 1] = obj4;
                        }
                        i15++;
                    } else {
                        if (obj3.equals(objArr[i19])) {
                            int i20 = i19 ^ 1;
                            Object obj5 = objArr[i20];
                            Objects.requireNonNull(obj5);
                            c0322a = new p.a.C0322a(obj3, obj4, obj5);
                            objArr[i20] = obj4;
                            break;
                        }
                        b10 = i18 + 1;
                    }
                }
                i14++;
            }
            return i15 == i10 ? bArr : new Object[]{bArr, Integer.valueOf(i15), c0322a};
        }
        if (i11 <= 32768) {
            short[] sArr = new short[i11];
            Arrays.fill(sArr, (short) -1);
            int i21 = 0;
            while (i14 < i10) {
                int i22 = (i14 * 2) + i12;
                int i23 = (i21 * 2) + i12;
                Object obj6 = objArr[i22];
                Objects.requireNonNull(obj6);
                Object obj7 = objArr[i22 ^ 1];
                Objects.requireNonNull(obj7);
                g.a(obj6, obj7);
                int b11 = m.b(obj6.hashCode());
                while (true) {
                    int i24 = b11 & i13;
                    int i25 = sArr[i24] & 65535;
                    if (i25 == 65535) {
                        sArr[i24] = (short) i23;
                        if (i21 < i14) {
                            objArr[i23] = obj6;
                            objArr[i23 ^ 1] = obj7;
                        }
                        i21++;
                    } else {
                        if (obj6.equals(objArr[i25])) {
                            int i26 = i25 ^ 1;
                            Object obj8 = objArr[i26];
                            Objects.requireNonNull(obj8);
                            c0322a = new p.a.C0322a(obj6, obj7, obj8);
                            objArr[i26] = obj7;
                            break;
                        }
                        b11 = i24 + 1;
                    }
                }
                i14++;
            }
            return i21 == i10 ? sArr : new Object[]{sArr, Integer.valueOf(i21), c0322a};
        }
        int[] iArr = new int[i11];
        Arrays.fill(iArr, -1);
        int i27 = 0;
        while (i14 < i10) {
            int i28 = (i14 * 2) + i12;
            int i29 = (i27 * 2) + i12;
            Object obj9 = objArr[i28];
            Objects.requireNonNull(obj9);
            Object obj10 = objArr[i28 ^ 1];
            Objects.requireNonNull(obj10);
            g.a(obj9, obj10);
            int b12 = m.b(obj9.hashCode());
            while (true) {
                int i30 = b12 & i13;
                int i31 = iArr[i30];
                if (i31 == -1) {
                    iArr[i30] = i29;
                    if (i27 < i14) {
                        objArr[i29] = obj9;
                        objArr[i29 ^ 1] = obj10;
                    }
                    i27++;
                } else {
                    if (obj9.equals(objArr[i31])) {
                        int i32 = i31 ^ 1;
                        Object obj11 = objArr[i32];
                        Objects.requireNonNull(obj11);
                        c0322a = new p.a.C0322a(obj9, obj10, obj11);
                        objArr[i32] = obj10;
                        break;
                    }
                    b12 = i30 + 1;
                }
            }
            i14++;
        }
        return i27 == i10 ? iArr : new Object[]{iArr, Integer.valueOf(i27), c0322a};
    }

    static Object p(Object obj, Object[] objArr, int i10, int i11, Object obj2) {
        if (obj2 == null) {
            return null;
        }
        if (i10 == 1) {
            Object obj3 = objArr[i11];
            Objects.requireNonNull(obj3);
            if (!obj3.equals(obj2)) {
                return null;
            }
            Object obj4 = objArr[i11 ^ 1];
            Objects.requireNonNull(obj4);
            return obj4;
        }
        if (obj == null) {
            return null;
        }
        if (obj instanceof byte[]) {
            byte[] bArr = (byte[]) obj;
            int length = bArr.length - 1;
            int b10 = m.b(obj2.hashCode());
            while (true) {
                int i12 = b10 & length;
                int i13 = bArr[i12] & 255;
                if (i13 == 255) {
                    return null;
                }
                if (obj2.equals(objArr[i13])) {
                    return objArr[i13 ^ 1];
                }
                b10 = i12 + 1;
            }
        } else if (obj instanceof short[]) {
            short[] sArr = (short[]) obj;
            int length2 = sArr.length - 1;
            int b11 = m.b(obj2.hashCode());
            while (true) {
                int i14 = b11 & length2;
                int i15 = sArr[i14] & 65535;
                if (i15 == 65535) {
                    return null;
                }
                if (obj2.equals(objArr[i15])) {
                    return objArr[i15 ^ 1];
                }
                b11 = i14 + 1;
            }
        } else {
            int[] iArr = (int[]) obj;
            int length3 = iArr.length - 1;
            int b12 = m.b(obj2.hashCode());
            while (true) {
                int i16 = b12 & length3;
                int i17 = iArr[i16];
                if (i17 == -1) {
                    return null;
                }
                if (obj2.equals(objArr[i17])) {
                    return objArr[i17 ^ 1];
                }
                b12 = i16 + 1;
            }
        }
    }

    @Override // com.google.common.collect.p
    r b() {
        return new a(this, this.f14253u, 0, this.f14254v);
    }

    @Override // com.google.common.collect.p
    r c() {
        return new b(this, new c(this.f14253u, 0, this.f14254v));
    }

    @Override // com.google.common.collect.p
    n d() {
        return new c(this.f14253u, 1, this.f14254v);
    }

    @Override // com.google.common.collect.p, java.util.Map
    public Object get(Object obj) {
        Object p10 = p(this.f14252t, this.f14253u, this.f14254v, 0, obj);
        if (p10 == null) {
            return null;
        }
        return p10;
    }

    @Override // java.util.Map
    public int size() {
        return this.f14254v;
    }
}
