2021-08-03 07:33:18 +00:00
|
|
|
package kotlin.ranges;
|
|
|
|
|
2021-11-02 06:38:17 +00:00
|
|
|
import d0.d0.b;
|
|
|
|
import d0.x.c;
|
2021-08-03 07:33:18 +00:00
|
|
|
import java.util.Iterator;
|
|
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
|
|
/* compiled from: Progressions.kt */
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-11-02 06:38:17 +00:00
|
|
|
public class IntProgression implements Iterable<Integer>, d0.z.d.g0.a {
|
2021-12-02 18:53:44 +00:00
|
|
|
public static final a j = new a(null);
|
2021-08-03 07:33:18 +00:00
|
|
|
public final int k;
|
|
|
|
public final int l;
|
2021-12-02 18:53:44 +00:00
|
|
|
public final int m;
|
2021-08-03 07:33:18 +00:00
|
|
|
|
|
|
|
/* compiled from: Progressions.kt */
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-08-03 07:33:18 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-02 18:53:44 +00:00
|
|
|
public IntProgression(int i, int i2, int i3) {
|
|
|
|
if (i3 == 0) {
|
2021-08-03 07:33:18 +00:00
|
|
|
throw new IllegalArgumentException("Step must be non-zero.");
|
2021-12-02 18:53:44 +00:00
|
|
|
} else if (i3 != Integer.MIN_VALUE) {
|
|
|
|
this.k = i;
|
|
|
|
this.l = c.getProgressionLastElement(i, i2, i3);
|
|
|
|
this.m = i3;
|
2021-08-03 07:33:18 +00:00
|
|
|
} 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;
|
2021-12-02 18:53:44 +00:00
|
|
|
if (!(this.k == intProgression.k && this.l == intProgression.l && this.m == intProgression.m)) {
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final int getFirst() {
|
2021-12-02 18:53:44 +00:00
|
|
|
return this.k;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public final int getLast() {
|
2021-12-02 18:53:44 +00:00
|
|
|
return this.l;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public final int getStep() {
|
2021-12-02 18:53:44 +00:00
|
|
|
return this.m;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
if (isEmpty()) {
|
|
|
|
return -1;
|
|
|
|
}
|
2021-12-02 18:53:44 +00:00
|
|
|
return (((this.k * 31) + this.l) * 31) + this.m;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isEmpty() {
|
2021-12-02 18:53:44 +00:00
|
|
|
if (this.m > 0) {
|
|
|
|
if (this.k > this.l) {
|
2021-08-03 07:33:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
2021-12-02 18:53:44 +00:00
|
|
|
} else if (this.k < this.l) {
|
2021-08-03 07:33:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // java.lang.Iterable
|
2022-03-07 09:34:54 +00:00
|
|
|
/* renamed from: iterator */
|
|
|
|
public Iterator<Integer> iterator2() {
|
2021-12-02 18:53:44 +00:00
|
|
|
return new b(this.k, this.l, this.m);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2021-12-02 18:53:44 +00:00
|
|
|
int i;
|
2021-08-03 07:33:18 +00:00
|
|
|
StringBuilder sb;
|
2021-12-02 18:53:44 +00:00
|
|
|
if (this.m > 0) {
|
2021-08-03 07:33:18 +00:00
|
|
|
sb = new StringBuilder();
|
|
|
|
sb.append(this.k);
|
2021-12-02 18:53:44 +00:00
|
|
|
sb.append("..");
|
|
|
|
sb.append(this.l);
|
2021-08-03 07:33:18 +00:00
|
|
|
sb.append(" step ");
|
2021-12-02 18:53:44 +00:00
|
|
|
i = this.m;
|
2021-08-03 07:33:18 +00:00
|
|
|
} else {
|
|
|
|
sb = new StringBuilder();
|
|
|
|
sb.append(this.k);
|
2021-12-02 18:53:44 +00:00
|
|
|
sb.append(" downTo ");
|
|
|
|
sb.append(this.l);
|
2021-08-03 07:33:18 +00:00
|
|
|
sb.append(" step ");
|
2021-12-02 18:53:44 +00:00
|
|
|
i = -this.m;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
2021-12-02 18:53:44 +00:00
|
|
|
sb.append(i);
|
2021-08-03 07:33:18 +00:00
|
|
|
return sb.toString();
|
|
|
|
}
|
|
|
|
}
|