package com.google.common.collect;

import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;

/* JADX INFO: loaded from: classes2.dex */
public class e implements Iterator {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f23654a = 0;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Iterator f23655b;

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ Object f23657d;

    public e(n nVar) {
        this.f23657d = nVar;
        Collection collection = nVar.f23697b;
        this.f23656c = collection;
        this.f23655b = collection instanceof List ? ((List) collection).listIterator() : collection.iterator();
    }

    public final void a() {
        Object obj = this.f23657d;
        ((n) obj).f();
        if (((n) obj).f23697b != ((Collection) this.f23656c)) {
            throw new ConcurrentModificationException();
        }
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        int i10 = this.f23654a;
        Iterator it = this.f23655b;
        switch (i10) {
            case 0:
                break;
            case 1:
                break;
            default:
                a();
                break;
        }
        return it.hasNext();
    }

    @Override // java.util.Iterator
    public final Object next() {
        int i10 = this.f23654a;
        Iterator it = this.f23655b;
        switch (i10) {
            case 0:
                Map.Entry entry = (Map.Entry) it.next();
                this.f23656c = (Collection) entry.getValue();
                return ((f) this.f23657d).d(entry);
            case 1:
                Map.Entry entry2 = (Map.Entry) it.next();
                this.f23656c = entry2;
                return entry2.getKey();
            default:
                a();
                return it.next();
        }
    }

    @Override // java.util.Iterator
    public final void remove() {
        int i10 = this.f23654a;
        Object obj = this.f23657d;
        Iterator it = this.f23655b;
        switch (i10) {
            case 0:
                com.google.common.base.h.i(((Collection) this.f23656c) != null, "no calls to next() since the last call to remove()");
                it.remove();
                ((f) obj).f23661d.f23569f -= ((Collection) this.f23656c).size();
                ((Collection) this.f23656c).clear();
                this.f23656c = null;
                break;
            case 1:
                com.google.common.base.h.i(((Map.Entry) this.f23656c) != null, "no calls to next() since the last call to remove()");
                Collection collection = (Collection) ((Map.Entry) this.f23656c).getValue();
                it.remove();
                ((h) obj).f23676c.f23569f -= collection.size();
                collection.clear();
                this.f23656c = null;
                break;
            default:
                it.remove();
                n nVar = (n) obj;
                nVar.f23700e.f23569f--;
                nVar.g();
                break;
        }
    }

    public e(n nVar, ListIterator listIterator) {
        this.f23657d = nVar;
        this.f23656c = nVar.f23697b;
        this.f23655b = listIterator;
    }

    public e(h hVar, Iterator it) {
        this.f23655b = it;
        this.f23657d = hVar;
    }

    public e(f fVar) {
        this.f23657d = fVar;
        this.f23655b = fVar.f23660c.entrySet().iterator();
    }
}
