package t4;

import java.io.Closeable;
import java.util.ArrayList;
import java.util.Iterator;

/* JADX INFO: loaded from: classes.dex */
public final class f implements Closeable {

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

    public f(Iterator it) {
        this.f32951a = it;
    }

    public static f x(Iterable iterable) {
        iterable.getClass();
        return new f(new v4.a(iterable));
    }

    public final ArrayList E() {
        ArrayList arrayList = new ArrayList();
        while (true) {
            Iterator it = this.f32951a;
            if (!it.hasNext()) {
                return arrayList;
            }
            arrayList.add(it.next());
        }
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() {
    }

    public final f e(u4.c cVar) {
        return new f(new w4.e(this.f32951a, cVar));
    }

    public final d g() {
        Iterator it = this.f32951a;
        return it.hasNext() ? new d(it.next()) : d.f32946b;
    }

    public final Object k() {
        Iterator it = this.f32951a;
        if (it.hasNext()) {
            return it.next();
        }
        return null;
    }

    public final f m(u4.a aVar) {
        return new f(new w4.f(this.f32951a, aVar));
    }

    public final boolean p(u4.c cVar, int i10) {
        boolean zTest;
        boolean z10 = i10 == 0;
        boolean z11 = i10 == 1;
        do {
            Iterator it = this.f32951a;
            if (!it.hasNext()) {
                return !z10;
            }
            zTest = cVar.test(it.next());
        } while (!(zTest ^ z11));
        return z10 && zTest;
    }
}
