package com.google.common.collect;

import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;

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

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Object f23668b = null;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public Collection f23669c = null;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Iterator f23670d = Iterators$EmptyModifiableIterator.f23610a;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final /* synthetic */ AbstractMapBasedMultimap f23671e;

    public g(AbstractMapBasedMultimap abstractMapBasedMultimap) {
        this.f23671e = abstractMapBasedMultimap;
        this.f23667a = abstractMapBasedMultimap.f23568e.entrySet().iterator();
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        return this.f23667a.hasNext() || this.f23670d.hasNext();
    }

    @Override // java.util.Iterator
    public final Object next() {
        if (!this.f23670d.hasNext()) {
            Map.Entry entry = (Map.Entry) this.f23667a.next();
            this.f23668b = entry.getKey();
            Collection collection = (Collection) entry.getValue();
            this.f23669c = collection;
            this.f23670d = collection.iterator();
        }
        Object obj = this.f23668b;
        Object next = this.f23670d.next();
        switch (((c) this).f23647f) {
            case 0:
                return next;
            default:
                return new ImmutableEntry(obj, next);
        }
    }

    @Override // java.util.Iterator
    public final void remove() {
        this.f23670d.remove();
        Collection collection = this.f23669c;
        Objects.requireNonNull(collection);
        if (collection.isEmpty()) {
            this.f23667a.remove();
        }
        AbstractMapBasedMultimap abstractMapBasedMultimap = this.f23671e;
        abstractMapBasedMultimap.f23569f--;
    }
}
