package C6;

import java.util.AbstractList;
import java.util.ConcurrentModificationException;
import java.util.ListIterator;
import java.util.NoSuchElementException;
import n4.u0;

/* JADX INFO: loaded from: classes.dex */
public final class a implements ListIterator, Q6.a {

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public int f1373r;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public int f1375t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public final B6.f f1376u;

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

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public int f1374s = -1;

    public a(c cVar, int i) {
        this.f1376u = cVar;
        this.f1373r = i;
        this.f1375t = ((AbstractList) cVar).modCount;
    }

    public void a() {
        if (((AbstractList) ((b) this.f1376u).f1381u).modCount != this.f1375t) {
            throw new ConcurrentModificationException();
        }
    }

    @Override // java.util.ListIterator
    public final void add(Object obj) {
        switch (this.f1372q) {
            case u0.f15495q /* 0 */:
                a();
                int i = this.f1373r;
                this.f1373r = i + 1;
                b bVar = (b) this.f1376u;
                bVar.add(i, obj);
                this.f1374s = -1;
                this.f1375t = ((AbstractList) bVar).modCount;
                break;
            default:
                b();
                int i5 = this.f1373r;
                this.f1373r = i5 + 1;
                c cVar = (c) this.f1376u;
                cVar.add(i5, obj);
                this.f1374s = -1;
                this.f1375t = ((AbstractList) cVar).modCount;
                break;
        }
    }

    public void b() {
        if (((AbstractList) ((c) this.f1376u)).modCount != this.f1375t) {
            throw new ConcurrentModificationException();
        }
    }

    @Override // java.util.ListIterator, java.util.Iterator
    public final boolean hasNext() {
        switch (this.f1372q) {
            case u0.f15495q /* 0 */:
                if (this.f1373r < ((b) this.f1376u).f1379s) {
                }
                break;
            default:
                if (this.f1373r < ((c) this.f1376u).f1384r) {
                }
                break;
        }
        return false;
    }

    @Override // java.util.ListIterator
    public final boolean hasPrevious() {
        switch (this.f1372q) {
            case u0.f15495q /* 0 */:
                if (this.f1373r > 0) {
                }
                break;
            default:
                if (this.f1373r > 0) {
                }
                break;
        }
        return false;
    }

    @Override // java.util.ListIterator, java.util.Iterator
    public final Object next() {
        switch (this.f1372q) {
            case u0.f15495q /* 0 */:
                a();
                int i = this.f1373r;
                b bVar = (b) this.f1376u;
                if (i >= bVar.f1379s) {
                    throw new NoSuchElementException();
                }
                this.f1373r = i + 1;
                this.f1374s = i;
                return bVar.f1377q[bVar.f1378r + i];
            default:
                b();
                int i5 = this.f1373r;
                c cVar = (c) this.f1376u;
                if (i5 >= cVar.f1384r) {
                    throw new NoSuchElementException();
                }
                this.f1373r = i5 + 1;
                this.f1374s = i5;
                return cVar.f1383q[i5];
        }
    }

    @Override // java.util.ListIterator
    public final int nextIndex() {
        switch (this.f1372q) {
        }
        return this.f1373r;
    }

    @Override // java.util.ListIterator
    public final Object previous() {
        switch (this.f1372q) {
            case u0.f15495q /* 0 */:
                a();
                int i = this.f1373r;
                if (i <= 0) {
                    throw new NoSuchElementException();
                }
                int i5 = i - 1;
                this.f1373r = i5;
                this.f1374s = i5;
                b bVar = (b) this.f1376u;
                return bVar.f1377q[bVar.f1378r + i5];
            default:
                b();
                int i8 = this.f1373r;
                if (i8 <= 0) {
                    throw new NoSuchElementException();
                }
                int i9 = i8 - 1;
                this.f1373r = i9;
                this.f1374s = i9;
                return ((c) this.f1376u).f1383q[i9];
        }
    }

    @Override // java.util.ListIterator
    public final int previousIndex() {
        switch (this.f1372q) {
        }
        return this.f1373r - 1;
    }

    @Override // java.util.ListIterator, java.util.Iterator
    public final void remove() {
        switch (this.f1372q) {
            case u0.f15495q /* 0 */:
                a();
                int i = this.f1374s;
                if (i == -1) {
                    throw new IllegalStateException("Call next() or previous() before removing element from the iterator.");
                }
                b bVar = (b) this.f1376u;
                bVar.b(i);
                this.f1373r = this.f1374s;
                this.f1374s = -1;
                this.f1375t = ((AbstractList) bVar).modCount;
                return;
            default:
                b();
                int i5 = this.f1374s;
                if (i5 == -1) {
                    throw new IllegalStateException("Call next() or previous() before removing element from the iterator.");
                }
                c cVar = (c) this.f1376u;
                cVar.b(i5);
                this.f1373r = this.f1374s;
                this.f1374s = -1;
                this.f1375t = ((AbstractList) cVar).modCount;
                return;
        }
    }

    @Override // java.util.ListIterator
    public final void set(Object obj) {
        switch (this.f1372q) {
            case u0.f15495q /* 0 */:
                a();
                int i = this.f1374s;
                if (i == -1) {
                    throw new IllegalStateException("Call next() or previous() before replacing element from the iterator.");
                }
                ((b) this.f1376u).set(i, obj);
                return;
            default:
                b();
                int i5 = this.f1374s;
                if (i5 == -1) {
                    throw new IllegalStateException("Call next() or previous() before replacing element from the iterator.");
                }
                ((c) this.f1376u).set(i5, obj);
                return;
        }
    }

    public a(b bVar, int i) {
        this.f1376u = bVar;
        this.f1373r = i;
        this.f1375t = ((AbstractList) bVar).modCount;
    }
}
