package n;

import androidx.annotation.Nullable;
import java.util.Iterator;
import java.util.Map;
import java.util.WeakHashMap;

/* JADX INFO: loaded from: classes.dex */
public class g implements Iterable {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public c f30713a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public c f30714b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final WeakHashMap f30715c = new WeakHashMap();

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f30716d = 0;

    public Object c(Object obj) {
        c cVar = get(obj);
        if (cVar == null) {
            return null;
        }
        this.f30716d--;
        WeakHashMap weakHashMap = this.f30715c;
        if (!weakHashMap.isEmpty()) {
            Iterator it = weakHashMap.keySet().iterator();
            while (it.hasNext()) {
                ((f) it.next()).a(cVar);
            }
        }
        c cVar2 = cVar.f30707d;
        if (cVar2 != null) {
            cVar2.f30706c = cVar.f30706c;
        } else {
            this.f30713a = cVar.f30706c;
        }
        c cVar3 = cVar.f30706c;
        if (cVar3 != null) {
            cVar3.f30707d = cVar2;
        } else {
            this.f30714b = cVar2;
        }
        cVar.f30706c = null;
        cVar.f30707d = null;
        return cVar.f30705b;
    }

    @Nullable
    public Map.Entry<Object, Object> eldest() {
        return this.f30713a;
    }

    /* JADX WARN: Code restructure failed: missing block: B:24:0x0048, code lost:
    
        if (r3.hasNext() != false) goto L28;
     */
    /* JADX WARN: Code restructure failed: missing block: B:26:0x0050, code lost:
    
        if (((n.e) r7).hasNext() != false) goto L28;
     */
    /* JADX WARN: Code restructure failed: missing block: B:29:0x0054, code lost:
    
        return false;
     */
    /* JADX WARN: Code restructure failed: missing block: B:38:?, code lost:
    
        return true;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof g)) {
            return false;
        }
        g gVar = (g) obj;
        if (this.f30716d != gVar.f30716d) {
            return false;
        }
        Iterator it = iterator();
        Iterator it2 = gVar.iterator();
        while (true) {
            e eVar = (e) it;
            if (!eVar.hasNext()) {
                break;
            }
            e eVar2 = (e) it2;
            if (!eVar2.hasNext()) {
                break;
            }
            Map.Entry entry = (Map.Entry) eVar.next();
            Object next = eVar2.next();
            if ((entry == null && next != null) || (entry != null && !entry.equals(next))) {
                break;
            }
        }
        return false;
    }

    @Nullable
    public c get(Object obj) {
        c cVar = this.f30713a;
        while (cVar != null && !cVar.f30704a.equals(obj)) {
            cVar = cVar.f30706c;
        }
        return cVar;
    }

    public final int hashCode() {
        Iterator it = iterator();
        int iHashCode = 0;
        while (true) {
            e eVar = (e) it;
            if (!eVar.hasNext()) {
                return iHashCode;
            }
            iHashCode += ((Map.Entry) eVar.next()).hashCode();
        }
    }

    @Override // java.lang.Iterable
    public final Iterator iterator() {
        b bVar = new b(this.f30713a, this.f30714b, 0);
        this.f30715c.put(bVar, Boolean.FALSE);
        return bVar;
    }

    @Nullable
    public Map.Entry<Object, Object> newest() {
        return this.f30714b;
    }

    public final String toString() {
        StringBuilder sb = new StringBuilder("[");
        Iterator it = iterator();
        while (true) {
            e eVar = (e) it;
            if (!eVar.hasNext()) {
                sb.append("]");
                return sb.toString();
            }
            sb.append(((Map.Entry) eVar.next()).toString());
            if (eVar.hasNext()) {
                sb.append(", ");
            }
        }
    }
}
