package defpackage;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

/* JADX INFO: renamed from: ᵡˆᵫ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C3197 implements Map, Serializable, InterfaceC5238 {

    /* JADX INFO: renamed from: ˁˌᵩ, reason: contains not printable characters */
    public static final C3197 f12141;

    /* JADX INFO: renamed from: ʿٴˇ, reason: contains not printable characters */
    public C0517 f12142;

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public int f12143;

    /* JADX INFO: renamed from: ˉᵵᵜ, reason: contains not printable characters */
    public boolean f12144;

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public Object[] f12145;

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public int f12146;

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public C3497 f12147;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public int[] f12148;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public Object[] f12149;

    /* JADX INFO: renamed from: ᵠˏˏ, reason: contains not printable characters */
    public C3497 f12150;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public int[] f12151;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public int f12152;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public int f12153;

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public int f12154;

    static {
        C3197 c3197 = new C3197(0);
        c3197.f12144 = true;
        f12141 = c3197;
    }

    public C3197() {
        this(8);
    }

    public C3197(int i) {
        if (i < 0) {
            ᵕᵩʽᵲ.ᵮᵣᵗˈ("capacity must be non-negative.");
            throw null;
        }
        Object[] objArr = new Object[i];
        int[] iArr = new int[i];
        int iHighestOneBit = Integer.highestOneBit((i < 1 ? 1 : i) * 3);
        this.f12145 = objArr;
        this.f12149 = null;
        this.f12148 = iArr;
        this.f12151 = new int[iHighestOneBit];
        this.f12152 = 2;
        this.f12153 = 0;
        this.f12143 = Integer.numberOfLeadingZeros(iHighestOneBit) + 1;
    }

    @Override // java.util.Map
    public final void clear() {
        m7330();
        int i = this.f12153 - 1;
        if (i >= 0) {
            int i2 = 0;
            while (true) {
                int[] iArr = this.f12148;
                int i3 = iArr[i2];
                if (i3 >= 0) {
                    this.f12151[i3] = 0;
                    iArr[i2] = -1;
                }
                if (i2 == i) {
                    break;
                } else {
                    i2++;
                }
            }
        }
        ᵘᵞʿⁱ.ᵸˆˁ(this.f12145, 0, this.f12153);
        Object[] objArr = this.f12149;
        if (objArr != null) {
            ᵘᵞʿⁱ.ᵸˆˁ(objArr, 0, this.f12153);
        }
        this.f12154 = 0;
        this.f12153 = 0;
        this.f12146++;
    }

    @Override // java.util.Map
    public final boolean containsKey(Object obj) {
        return m7336(obj) >= 0;
    }

    @Override // java.util.Map
    public final boolean containsValue(Object obj) {
        int i;
        int i2 = this.f12153;
        while (true) {
            i = -1;
            i2--;
            if (i2 >= 0) {
                if (this.f12148[i2] >= 0 && ᵥˈᵛ.ˊᵫᵗ(this.f12149[i2], obj)) {
                    i = i2;
                    break;
                }
            } else {
                break;
            }
        }
        return i >= 0;
    }

    @Override // java.util.Map
    public final Set entrySet() {
        C3497 c3497 = this.f12150;
        if (c3497 != null) {
            return c3497;
        }
        C3497 c34972 = new C3497(this, 0);
        this.f12150 = c34972;
        return c34972;
    }

    @Override // java.util.Map
    public final boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (obj instanceof Map) {
            Map map = (Map) obj;
            if (this.f12154 == map.size()) {
                for (Object obj2 : map.entrySet()) {
                    if (obj2 != null) {
                        try {
                            Map.Entry entry = (Map.Entry) obj2;
                            int iM7336 = m7336(entry.getKey());
                            if (!(iM7336 < 0 ? false : ᵥˈᵛ.ˊᵫᵗ(this.f12149[iM7336], entry.getValue()))) {
                            }
                        } catch (ClassCastException unused) {
                        }
                    }
                }
                return true;
            }
        }
        return false;
    }

    @Override // java.util.Map
    public final Object get(Object obj) {
        int iM7336 = m7336(obj);
        if (iM7336 < 0) {
            return null;
        }
        return this.f12149[iM7336];
    }

    @Override // java.util.Map
    public final int hashCode() {
        C2467 c2467 = new C2467(this, 0);
        int i = 0;
        while (c2467.hasNext()) {
            int i2 = c2467.f10234;
            C3197 c3197 = (C3197) c2467.f10237;
            if (i2 >= c3197.f12153) {
                C4468.m9518();
                return 0;
            }
            c2467.f10234 = i2 + 1;
            c2467.f10236 = i2;
            Object obj = c3197.f12145[i2];
            int iHashCode = obj != null ? obj.hashCode() : 0;
            Object obj2 = c3197.f12149[c2467.f10236];
            int iHashCode2 = obj2 != null ? obj2.hashCode() : 0;
            c2467.m6398();
            i += iHashCode ^ iHashCode2;
        }
        return i;
    }

    @Override // java.util.Map
    public final boolean isEmpty() {
        return this.f12154 == 0;
    }

    @Override // java.util.Map
    public final Set keySet() {
        C3497 c3497 = this.f12147;
        if (c3497 != null) {
            return c3497;
        }
        C3497 c34972 = new C3497(this, 1);
        this.f12147 = c34972;
        return c34972;
    }

    @Override // java.util.Map
    public final Object put(Object obj, Object obj2) {
        m7330();
        int iM7332 = m7332(obj);
        Object[] objArr = this.f12149;
        if (objArr == null) {
            int length = this.f12145.length;
            if (length < 0) {
                ᵕᵩʽᵲ.ᵮᵣᵗˈ("capacity must be non-negative.");
                return null;
            }
            objArr = new Object[length];
            this.f12149 = objArr;
        }
        if (iM7332 >= 0) {
            objArr[iM7332] = obj2;
            return null;
        }
        int i = (-iM7332) - 1;
        Object obj3 = objArr[i];
        objArr[i] = obj2;
        return obj3;
    }

    @Override // java.util.Map
    public final void putAll(Map map) {
        m7330();
        Set<Map.Entry> setEntrySet = map.entrySet();
        if (setEntrySet.isEmpty()) {
            return;
        }
        m7331(setEntrySet.size());
        for (Map.Entry entry : setEntrySet) {
            int iM7332 = m7332(entry.getKey());
            Object[] objArr = this.f12149;
            if (objArr == null) {
                int length = this.f12145.length;
                if (length < 0) {
                    ᵕᵩʽᵲ.ᵮᵣᵗˈ("capacity must be non-negative.");
                    return;
                } else {
                    objArr = new Object[length];
                    this.f12149 = objArr;
                }
            }
            if (iM7332 >= 0) {
                objArr[iM7332] = entry.getValue();
            } else {
                int i = (-iM7332) - 1;
                if (!ᵥˈᵛ.ˊᵫᵗ(entry.getValue(), objArr[i])) {
                    objArr[i] = entry.getValue();
                }
            }
        }
    }

    @Override // java.util.Map
    public final Object remove(Object obj) {
        m7330();
        int iM7336 = m7336(obj);
        if (iM7336 < 0) {
            return null;
        }
        Object obj2 = this.f12149[iM7336];
        m7335(iM7336);
        return obj2;
    }

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

    public final String toString() {
        StringBuilder sb = new StringBuilder((this.f12154 * 3) + 2);
        sb.append("{");
        int i = 0;
        C2467 c2467 = new C2467(this, 0);
        while (c2467.hasNext()) {
            if (i > 0) {
                sb.append(", ");
            }
            int i2 = c2467.f10234;
            C3197 c3197 = (C3197) c2467.f10237;
            if (i2 >= c3197.f12153) {
                C4468.m9518();
                return null;
            }
            c2467.f10234 = i2 + 1;
            c2467.f10236 = i2;
            Object obj = c3197.f12145[i2];
            if (obj == c3197) {
                sb.append("(this Map)");
            } else {
                sb.append(obj);
            }
            sb.append('=');
            Object obj2 = c3197.f12149[c2467.f10236];
            if (obj2 == c3197) {
                sb.append("(this Map)");
            } else {
                sb.append(obj2);
            }
            c2467.m6398();
            i++;
        }
        sb.append("}");
        return sb.toString();
    }

    @Override // java.util.Map
    public final Collection values() {
        C0517 c0517 = this.f12142;
        if (c0517 != null) {
            return c0517;
        }
        C0517 c05172 = new C0517(this);
        this.f12142 = c05172;
        return c05172;
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final C3197 m7328() {
        m7330();
        this.f12144 = true;
        return this.f12154 > 0 ? this : f12141;
    }

    /* JADX WARN: Code restructure failed: missing block: B:11:0x0032, code lost:
    
        r3[r0] = r6;
        r5.f12148[r2] = r0;
        r2 = r6;
     */
    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m7329(int i) {
        this.f12146++;
        int i2 = 0;
        if (this.f12153 > this.f12154) {
            m7334(false);
        }
        this.f12151 = new int[i];
        this.f12143 = Integer.numberOfLeadingZeros(i) + 1;
        while (i2 < this.f12153) {
            int i3 = i2 + 1;
            int iM7333 = m7333(this.f12145[i2]);
            int i4 = this.f12152;
            while (true) {
                int[] iArr = this.f12151;
                if (iArr[iM7333] == 0) {
                    break;
                }
                i4--;
                if (i4 < 0) {
                    ᵕᵩʽᵲ.ᵪᵹᵥᵻ("This cannot happen with fixed magic multiplier and grow-only hash array. Have object hashCodes changed?");
                    return;
                }
                iM7333 = iM7333 == 0 ? iArr.length - 1 : iM7333 - 1;
            }
        }
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final void m7330() {
        if (this.f12144) {
            C1390.m3978();
        }
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final void m7331(int i) {
        Object[] objArr = this.f12145;
        int length = objArr.length;
        int i2 = this.f12153;
        int i3 = length - i2;
        int i4 = i2 - this.f12154;
        if (i3 < i && i3 + i4 >= i && i4 >= objArr.length / 4) {
            m7334(true);
            return;
        }
        int i5 = i2 + i;
        if (i5 < 0) {
            throw new OutOfMemoryError();
        }
        if (i5 > objArr.length) {
            int length2 = objArr.length;
            int i6 = length2 + (length2 >> 1);
            if (i6 - i5 < 0) {
                i6 = i5;
            }
            if (i6 - 2147483639 > 0) {
                i6 = i5 > 2147483639 ? Integer.MAX_VALUE : 2147483639;
            }
            this.f12145 = Arrays.copyOf(objArr, i6);
            Object[] objArr2 = this.f12149;
            this.f12149 = objArr2 != null ? Arrays.copyOf(objArr2, i6) : null;
            this.f12148 = Arrays.copyOf(this.f12148, i6);
            int iHighestOneBit = Integer.highestOneBit((i6 >= 1 ? i6 : 1) * 3);
            if (iHighestOneBit > this.f12151.length) {
                m7329(iHighestOneBit);
            }
        }
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final int m7332(Object obj) {
        m7330();
        while (true) {
            int iM7333 = m7333(obj);
            int i = this.f12152 * 2;
            int length = this.f12151.length / 2;
            if (i > length) {
                i = length;
            }
            int i2 = 0;
            while (true) {
                int[] iArr = this.f12151;
                int i3 = iArr[iM7333];
                if (i3 == 0) {
                    int i4 = this.f12153;
                    Object[] objArr = this.f12145;
                    if (i4 < objArr.length) {
                        int i5 = i4 + 1;
                        this.f12153 = i5;
                        objArr[i4] = obj;
                        this.f12148[i4] = iM7333;
                        iArr[iM7333] = i5;
                        this.f12154++;
                        this.f12146++;
                        if (i2 > this.f12152) {
                            this.f12152 = i2;
                        }
                        return i4;
                    }
                    m7331(1);
                } else {
                    if (ᵥˈᵛ.ˊᵫᵗ(this.f12145[i3 - 1], obj)) {
                        return -i3;
                    }
                    i2++;
                    if (i2 > i) {
                        m7329(this.f12151.length * 2);
                        break;
                    }
                    iM7333 = iM7333 == 0 ? this.f12151.length - 1 : iM7333 - 1;
                }
            }
        }
    }

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public final int m7333(Object obj) {
        return ((obj != null ? obj.hashCode() : 0) * (-1640531527)) >>> this.f12143;
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final void m7334(boolean z) {
        int i;
        Object[] objArr = this.f12149;
        int i2 = 0;
        int i3 = 0;
        while (true) {
            i = this.f12153;
            if (i2 >= i) {
                break;
            }
            int[] iArr = this.f12148;
            int i4 = iArr[i2];
            if (i4 >= 0) {
                Object[] objArr2 = this.f12145;
                objArr2[i3] = objArr2[i2];
                if (objArr != null) {
                    objArr[i3] = objArr[i2];
                }
                if (z) {
                    iArr[i3] = i4;
                    this.f12151[i4] = i3 + 1;
                }
                i3++;
            }
            i2++;
        }
        ᵘᵞʿⁱ.ᵸˆˁ(this.f12145, i3, i);
        if (objArr != null) {
            ᵘᵞʿⁱ.ᵸˆˁ(objArr, i3, this.f12153);
        }
        this.f12153 = i3;
    }

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public final void m7335(int i) {
        int i2;
        int i3;
        int iM7333;
        int[] iArr;
        this.f12145[i] = null;
        Object[] objArr = this.f12149;
        if (objArr != null) {
            objArr[i] = null;
        }
        int length = this.f12148[i];
        loop0: while (true) {
            int i4 = length;
            int i5 = 0;
            do {
                length = length == 0 ? this.f12151.length - 1 : length - 1;
                int[] iArr2 = this.f12151;
                i2 = iArr2[length];
                i5++;
                if (i5 > this.f12152) {
                    iArr2[i4] = 0;
                    break loop0;
                } else if (i2 == 0) {
                    iArr2[i4] = 0;
                    break loop0;
                } else {
                    i3 = i2 - 1;
                    iM7333 = m7333(this.f12145[i3]) - length;
                    iArr = this.f12151;
                }
            } while ((iM7333 & (iArr.length - 1)) < i5);
            iArr[i4] = i2;
            this.f12148[i3] = i4;
        }
        this.f12148[i] = -1;
        this.f12154--;
        this.f12146++;
    }

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final int m7336(Object obj) {
        int iM7333 = m7333(obj);
        int i = this.f12152;
        while (true) {
            int i2 = this.f12151[iM7333];
            if (i2 == 0) {
                return -1;
            }
            int i3 = i2 - 1;
            if (ᵥˈᵛ.ˊᵫᵗ(this.f12145[i3], obj)) {
                return i3;
            }
            i--;
            if (i < 0) {
                return -1;
            }
            iM7333 = iM7333 == 0 ? this.f12151.length - 1 : iM7333 - 1;
        }
    }
}
