108 lines
2.9 KiB
Java
108 lines
2.9 KiB
Java
package kotlin.ranges;
|
|
|
|
import d0.d0.b;
|
|
import d0.x.c;
|
|
import java.util.Iterator;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: Progressions.kt */
|
|
/* loaded from: classes3.dex */
|
|
public class IntProgression implements Iterable<Integer>, d0.z.d.g0.a {
|
|
public static final a j = new a(null);
|
|
public final int k;
|
|
public final int l;
|
|
public final int m;
|
|
|
|
/* compiled from: Progressions.kt */
|
|
/* loaded from: classes3.dex */
|
|
public static final class a {
|
|
public a(DefaultConstructorMarker defaultConstructorMarker) {
|
|
}
|
|
|
|
public final IntProgression fromClosedRange(int i, int i2, int i3) {
|
|
return new IntProgression(i, i2, i3);
|
|
}
|
|
}
|
|
|
|
public IntProgression(int i, int i2, int i3) {
|
|
if (i3 == 0) {
|
|
throw new IllegalArgumentException("Step must be non-zero.");
|
|
} else if (i3 != Integer.MIN_VALUE) {
|
|
this.k = i;
|
|
this.l = c.getProgressionLastElement(i, i2, i3);
|
|
this.m = i3;
|
|
} else {
|
|
throw new IllegalArgumentException("Step must be greater than Int.MIN_VALUE to avoid overflow on negation.");
|
|
}
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (obj instanceof IntProgression) {
|
|
if (!isEmpty() || !((IntProgression) obj).isEmpty()) {
|
|
IntProgression intProgression = (IntProgression) obj;
|
|
if (!(this.k == intProgression.k && this.l == intProgression.l && this.m == intProgression.m)) {
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public final int getFirst() {
|
|
return this.k;
|
|
}
|
|
|
|
public final int getLast() {
|
|
return this.l;
|
|
}
|
|
|
|
public final int getStep() {
|
|
return this.m;
|
|
}
|
|
|
|
public int hashCode() {
|
|
if (isEmpty()) {
|
|
return -1;
|
|
}
|
|
return (((this.k * 31) + this.l) * 31) + this.m;
|
|
}
|
|
|
|
public boolean isEmpty() {
|
|
if (this.m > 0) {
|
|
if (this.k > this.l) {
|
|
return true;
|
|
}
|
|
} else if (this.k < this.l) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // java.lang.Iterable
|
|
/* renamed from: iterator */
|
|
public Iterator<Integer> iterator2() {
|
|
return new b(this.k, this.l, this.m);
|
|
}
|
|
|
|
public String toString() {
|
|
int i;
|
|
StringBuilder sb;
|
|
if (this.m > 0) {
|
|
sb = new StringBuilder();
|
|
sb.append(this.k);
|
|
sb.append("..");
|
|
sb.append(this.l);
|
|
sb.append(" step ");
|
|
i = this.m;
|
|
} else {
|
|
sb = new StringBuilder();
|
|
sb.append(this.k);
|
|
sb.append(" downTo ");
|
|
sb.append(this.l);
|
|
sb.append(" step ");
|
|
i = -this.m;
|
|
}
|
|
sb.append(i);
|
|
return sb.toString();
|
|
}
|
|
}
|