264 lines
7.8 KiB
Java
264 lines
7.8 KiB
Java
|
package o;
|
||
|
|
||
|
import java.io.Closeable;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Collections;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
import java.util.NoSuchElementException;
|
||
|
import o.KZr;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public final class YKU<T> implements Closeable {
|
||
|
public final C15901jVT a;
|
||
|
public final Iterator<? extends T> b;
|
||
|
|
||
|
public static <T> YKU<T> c(T... tArr) {
|
||
|
if (tArr.length != 0) {
|
||
|
return new YKU<>(new lBm(tArr));
|
||
|
}
|
||
|
return new YKU<>(Collections.emptyList());
|
||
|
}
|
||
|
|
||
|
public static <T> YKU<T> a(YKU<? extends T> yku, YKU<? extends T> yku2) {
|
||
|
YKU yku3 = new YKU(new C0717Mzi(yku.b, yku2.b));
|
||
|
KZr.AnonymousClass2 anonymousClass2 = new Runnable(yku, yku2) { // from class: o.KZr.2
|
||
|
private Closeable d;
|
||
|
private Closeable e;
|
||
|
|
||
|
public AnonymousClass2(Closeable yku4, Closeable yku22) {
|
||
|
this.e = yku4;
|
||
|
this.d = yku22;
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.Runnable
|
||
|
public final void run() {
|
||
|
try {
|
||
|
this.e.close();
|
||
|
try {
|
||
|
this.d.close();
|
||
|
} catch (Throwable th) {
|
||
|
if (th instanceof RuntimeException) {
|
||
|
throw ((RuntimeException) th);
|
||
|
}
|
||
|
if (th instanceof Error) {
|
||
|
throw ((Error) th);
|
||
|
}
|
||
|
throw new RuntimeException(th);
|
||
|
}
|
||
|
} catch (Throwable th2) {
|
||
|
try {
|
||
|
this.d.close();
|
||
|
} catch (Throwable unused) {
|
||
|
}
|
||
|
if (th2 instanceof RuntimeException) {
|
||
|
throw ((RuntimeException) th2);
|
||
|
}
|
||
|
throw ((Error) th2);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
C15901jVT c15901jVT = yku3.a;
|
||
|
if (c15901jVT == null) {
|
||
|
c15901jVT = new C15901jVT();
|
||
|
c15901jVT.c = anonymousClass2;
|
||
|
} else {
|
||
|
c15901jVT.c = new Runnable(c15901jVT.c, anonymousClass2) { // from class: o.KZr.3
|
||
|
private Runnable a;
|
||
|
private Runnable d;
|
||
|
|
||
|
public AnonymousClass3(Runnable runnable, Runnable anonymousClass22) {
|
||
|
this.a = runnable;
|
||
|
this.d = anonymousClass22;
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.Runnable
|
||
|
public final void run() {
|
||
|
try {
|
||
|
this.a.run();
|
||
|
this.d.run();
|
||
|
} catch (Throwable th) {
|
||
|
try {
|
||
|
this.d.run();
|
||
|
} catch (Throwable unused) {
|
||
|
}
|
||
|
if (th instanceof RuntimeException) {
|
||
|
throw ((RuntimeException) th);
|
||
|
}
|
||
|
throw ((Error) th);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
return new YKU<>(c15901jVT, yku3.b);
|
||
|
}
|
||
|
|
||
|
public YKU(Iterator<? extends T> it) {
|
||
|
this(null, it);
|
||
|
}
|
||
|
|
||
|
public YKU(Iterable<? extends T> iterable) {
|
||
|
this(null, new paq(iterable));
|
||
|
}
|
||
|
|
||
|
public YKU(C15901jVT c15901jVT, Iterator<? extends T> it) {
|
||
|
this.a = c15901jVT;
|
||
|
this.b = it;
|
||
|
}
|
||
|
|
||
|
public final YKU<T> e() {
|
||
|
return new YKU<>(this.a, new C3438axZ(this.b));
|
||
|
}
|
||
|
|
||
|
public final void d(qsu<? super T> qsuVar) {
|
||
|
while (this.b.hasNext()) {
|
||
|
qsuVar.d(this.b.next());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final <R> R d(R r, InterfaceC15902jVZ<? super R, ? super T, ? extends R> interfaceC15902jVZ) {
|
||
|
while (this.b.hasNext()) {
|
||
|
r = interfaceC15902jVZ.a(r, this.b.next());
|
||
|
}
|
||
|
return r;
|
||
|
}
|
||
|
|
||
|
public final zEQ<T> e(InterfaceC15902jVZ<T, T, T> interfaceC15902jVZ) {
|
||
|
boolean z = false;
|
||
|
T t = null;
|
||
|
while (this.b.hasNext()) {
|
||
|
T next = this.b.next();
|
||
|
if (z) {
|
||
|
t = interfaceC15902jVZ.a(t, next);
|
||
|
} else {
|
||
|
z = true;
|
||
|
t = next;
|
||
|
}
|
||
|
}
|
||
|
return z ? zEQ.a(t) : zEQ.d();
|
||
|
}
|
||
|
|
||
|
public final List<T> b() {
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
while (this.b.hasNext()) {
|
||
|
arrayList.add(this.b.next());
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public final <R, A> R a(InterfaceC12534ezy<? super T, A, R> interfaceC12534ezy) {
|
||
|
InterfaceC1244Ytw<A, R> anonymousClass7;
|
||
|
A e = interfaceC12534ezy.c().e();
|
||
|
while (this.b.hasNext()) {
|
||
|
interfaceC12534ezy.e().c(e, this.b.next());
|
||
|
}
|
||
|
if (interfaceC12534ezy.d() != null) {
|
||
|
anonymousClass7 = interfaceC12534ezy.d();
|
||
|
} else {
|
||
|
anonymousClass7 = new InterfaceC1244Ytw<A, R>() { // from class: o.PRA.7
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // o.InterfaceC1244Ytw
|
||
|
public final R d(A a) {
|
||
|
return a;
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
return anonymousClass7.d(e);
|
||
|
}
|
||
|
|
||
|
public final long c() {
|
||
|
long j = 0;
|
||
|
while (this.b.hasNext()) {
|
||
|
this.b.next();
|
||
|
j++;
|
||
|
}
|
||
|
return j;
|
||
|
}
|
||
|
|
||
|
public final T a() {
|
||
|
if (this.b.hasNext()) {
|
||
|
T next = this.b.next();
|
||
|
if (this.b.hasNext()) {
|
||
|
throw new IllegalStateException("Stream contains more than one element");
|
||
|
}
|
||
|
return next;
|
||
|
}
|
||
|
throw new NoSuchElementException("Stream contains no element");
|
||
|
}
|
||
|
|
||
|
@Override // java.io.Closeable, java.lang.AutoCloseable
|
||
|
public final void close() {
|
||
|
C15901jVT c15901jVT = this.a;
|
||
|
if (c15901jVT == null || c15901jVT.c == null) {
|
||
|
return;
|
||
|
}
|
||
|
this.a.c.run();
|
||
|
this.a.c = null;
|
||
|
}
|
||
|
|
||
|
public final boolean d(Jel<? super T> jel, int i) {
|
||
|
boolean z = i == 0;
|
||
|
boolean z2 = i == 1;
|
||
|
while (this.b.hasNext()) {
|
||
|
boolean e = jel.e(this.b.next());
|
||
|
if (e ^ z2) {
|
||
|
return z && e;
|
||
|
}
|
||
|
}
|
||
|
return !z;
|
||
|
}
|
||
|
|
||
|
public final YKU<T> b(Jel<? super T> jel) {
|
||
|
return new YKU<>(this.a, new GEP(this.b, new Jel<T>(jel) { // from class: o.Jel.HBt.3
|
||
|
private Jel b;
|
||
|
|
||
|
public AnonymousClass3(Jel jel2) {
|
||
|
this.b = jel2;
|
||
|
}
|
||
|
|
||
|
@Override // o.Jel
|
||
|
public final boolean e(T t) {
|
||
|
return !this.b.e(t);
|
||
|
}
|
||
|
}));
|
||
|
}
|
||
|
|
||
|
public final YKU<HzO<T>> d() {
|
||
|
return new YKU<>(this.a, new C0212Bks(new JtV(this.b), new InterfaceC3852bIt<T, HzO<T>>(this) { // from class: o.YKU.3
|
||
|
private YKU c;
|
||
|
|
||
|
{
|
||
|
this.c = this;
|
||
|
}
|
||
|
|
||
|
@Override // o.InterfaceC3852bIt
|
||
|
public final /* synthetic */ Object e(int i, Object obj) {
|
||
|
return new HzO(i, obj);
|
||
|
}
|
||
|
}));
|
||
|
}
|
||
|
|
||
|
public final YKU<T> c(long j) {
|
||
|
if (j < 0) {
|
||
|
throw new IllegalArgumentException("maxSize cannot be negative");
|
||
|
}
|
||
|
if (j != 0) {
|
||
|
return new YKU<>(this.a, new KeH(this.b, j));
|
||
|
}
|
||
|
return new YKU<>(Collections.emptyList());
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public final <R> R[] d(utN<R[]> utn) {
|
||
|
List c = MYy.c(this.b);
|
||
|
int size = c.size();
|
||
|
if (size < 2147483639) {
|
||
|
Object[] array = c.toArray(FXU.e(size, new Object[0]));
|
||
|
R[] d = utn.d(size);
|
||
|
System.arraycopy(array, 0, d, 0, size);
|
||
|
return d;
|
||
|
}
|
||
|
throw new IllegalArgumentException("Stream size exceeds max array size");
|
||
|
}
|
||
|
}
|