109 lines
2.9 KiB
Java
109 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 */
|
|
public class IntProgression implements Iterable<Integer>, d0.z.d.g0.a {
|
|
public static final a i = new a(null);
|
|
public final int j;
|
|
public final int k;
|
|
public final int l;
|
|
|
|
/* compiled from: Progressions.kt */
|
|
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 i2, int i3, int i4) {
|
|
if (i4 == 0) {
|
|
throw new IllegalArgumentException("Step must be non-zero.");
|
|
} else if (i4 != Integer.MIN_VALUE) {
|
|
this.j = i2;
|
|
this.k = c.getProgressionLastElement(i2, i3, i4);
|
|
this.l = i4;
|
|
} else {
|
|
throw new IllegalArgumentException("Step must be greater than Int.MIN_VALUE to avoid overflow on negation.");
|
|
}
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public boolean equals(Object obj) {
|
|
if (obj instanceof IntProgression) {
|
|
if (!isEmpty() || !((IntProgression) obj).isEmpty()) {
|
|
IntProgression intProgression = (IntProgression) obj;
|
|
if (!(this.j == intProgression.j && this.k == intProgression.k && this.l == intProgression.l)) {
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public final int getFirst() {
|
|
return this.j;
|
|
}
|
|
|
|
public final int getLast() {
|
|
return this.k;
|
|
}
|
|
|
|
public final int getStep() {
|
|
return this.l;
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public int hashCode() {
|
|
if (isEmpty()) {
|
|
return -1;
|
|
}
|
|
return (((this.j * 31) + this.k) * 31) + this.l;
|
|
}
|
|
|
|
public boolean isEmpty() {
|
|
if (this.l > 0) {
|
|
if (this.j > this.k) {
|
|
return true;
|
|
}
|
|
} else if (this.j < this.k) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/* Return type fixed from 'd0.t.c0' to match base method */
|
|
@Override // java.lang.Iterable
|
|
public Iterator<Integer> iterator() {
|
|
return new b(this.j, this.k, this.l);
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public String toString() {
|
|
int i2;
|
|
StringBuilder sb;
|
|
if (this.l > 0) {
|
|
sb = new StringBuilder();
|
|
sb.append(this.j);
|
|
sb.append("..");
|
|
sb.append(this.k);
|
|
sb.append(" step ");
|
|
i2 = this.l;
|
|
} else {
|
|
sb = new StringBuilder();
|
|
sb.append(this.j);
|
|
sb.append(" downTo ");
|
|
sb.append(this.k);
|
|
sb.append(" step ");
|
|
i2 = -this.l;
|
|
}
|
|
sb.append(i2);
|
|
return sb.toString();
|
|
}
|
|
}
|