New structure of range classes.
This commit is contained in:
@@ -4,81 +4,67 @@ public trait Range<in T : Comparable<T>> {
|
|||||||
public fun contains(item : T) : Boolean
|
public fun contains(item : T) : Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
public class IntRange(public val start : Int, public val size : Int) : Range<Int>, IntIterable {
|
public class IntRange(public val start : Int, public val end : Int) : Range<Int>, IntIterable {
|
||||||
public override fun iterator () : IntIterator
|
public override fun iterator () : IntIterator
|
||||||
|
|
||||||
public override fun contains (elem: Int) : Boolean
|
public override fun contains (elem: Int) : Boolean
|
||||||
|
|
||||||
public val end : Int
|
|
||||||
|
|
||||||
public class object {
|
public class object {
|
||||||
public val EMPTY: IntRange
|
public val EMPTY: IntRange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LongRange(public val start : Long, public val size : Long) : Range<Long>, LongIterable {
|
public class LongRange(public val start : Long, public val end : Long) : Range<Long>, LongIterable {
|
||||||
public override fun iterator () : LongIterator
|
public override fun iterator () : LongIterator
|
||||||
|
|
||||||
public override fun contains (elem: Long) : Boolean
|
public override fun contains (elem: Long) : Boolean
|
||||||
|
|
||||||
public val end : Long
|
|
||||||
|
|
||||||
public class object {
|
public class object {
|
||||||
public val EMPTY: LongRange
|
public val EMPTY: LongRange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ByteRange(public val start : Byte, public val size : Int) : Range<Byte>, ByteIterable {
|
public class ByteRange(public val start : Byte, public val end : Byte) : Range<Byte>, ByteIterable {
|
||||||
public override fun iterator () : ByteIterator
|
public override fun iterator () : ByteIterator
|
||||||
|
|
||||||
public override fun contains (elem: Byte) : Boolean
|
public override fun contains (elem: Byte) : Boolean
|
||||||
|
|
||||||
public val end : Byte
|
|
||||||
|
|
||||||
public class object {
|
public class object {
|
||||||
public val EMPTY: ByteRange
|
public val EMPTY: ByteRange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ShortRange(public val start : Short, public val size : Int) : Range<Short>, ShortIterable {
|
public class ShortRange(public val start : Short, public val end : Short) : Range<Short>, ShortIterable {
|
||||||
public override fun iterator () : ShortIterator
|
public override fun iterator () : ShortIterator
|
||||||
|
|
||||||
public override fun contains (elem: Short) : Boolean
|
public override fun contains (elem: Short) : Boolean
|
||||||
|
|
||||||
public val end : Short
|
|
||||||
|
|
||||||
public class object {
|
public class object {
|
||||||
public val EMPTY: ShortRange
|
public val EMPTY: ShortRange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CharRange(public val start : Char, public val size : Int) : Range<Char>, CharIterable {
|
public class CharRange(public val start : Char, public val end : Char) : Range<Char>, CharIterable {
|
||||||
public override fun iterator () : CharIterator
|
public override fun iterator () : CharIterator
|
||||||
|
|
||||||
public override fun contains (elem: Char) : Boolean
|
public override fun contains (elem: Char) : Boolean
|
||||||
|
|
||||||
public val end : Char
|
|
||||||
|
|
||||||
public class object {
|
public class object {
|
||||||
public val EMPTY: CharRange
|
public val EMPTY: CharRange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FloatRange(public val start : Float, public val size : Float) : Range<Float> {
|
public class FloatRange(public val start : Float, public val end : Float) : Range<Float> {
|
||||||
public override fun contains (elem: Float) : Boolean
|
public override fun contains (elem: Float) : Boolean
|
||||||
|
|
||||||
public val end : Float
|
|
||||||
|
|
||||||
public class object {
|
public class object {
|
||||||
public val EMPTY: FloatRange
|
public val EMPTY: FloatRange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DoubleRange(public val start : Double, public val size : Double) : Range<Double> {
|
public class DoubleRange(public val start : Double, public val end : Double) : Range<Double> {
|
||||||
public override fun contains (elem: Double) : Boolean
|
public override fun contains (elem: Double) : Boolean
|
||||||
|
|
||||||
public val end : Double
|
|
||||||
|
|
||||||
public class object {
|
public class object {
|
||||||
public val EMPTY: DoubleRange
|
public val EMPTY: DoubleRange
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
fun box(): String {
|
fun box(): String {
|
||||||
if (IntRange(0, 0) != IntRange.EMPTY) {
|
if (IntRange(1, 0) != IntRange.EMPTY) {
|
||||||
return IntRange.EMPTY.toString()
|
return IntRange.EMPTY.toString()
|
||||||
}
|
}
|
||||||
if (CharRange(0.toChar(), 0) != CharRange.EMPTY) {
|
if (CharRange(1.toChar(), 0.toChar()) != CharRange.EMPTY) {
|
||||||
return CharRange.EMPTY.toString()
|
return CharRange.EMPTY.toString()
|
||||||
}
|
}
|
||||||
if (ByteRange(0, 0) != ByteRange.EMPTY) {
|
if (ByteRange(1, 0) != ByteRange.EMPTY) {
|
||||||
return ByteRange.EMPTY.toString()
|
return ByteRange.EMPTY.toString()
|
||||||
}
|
}
|
||||||
if (ShortRange(0, 0) != ShortRange.EMPTY) {
|
if (ShortRange(1, 0) != ShortRange.EMPTY) {
|
||||||
return ShortRange.EMPTY.toString()
|
return ShortRange.EMPTY.toString()
|
||||||
}
|
}
|
||||||
if (FloatRange(0.toFloat(), 0.toFloat()) != FloatRange.EMPTY) {
|
if (FloatRange(1.toFloat(), 0.toFloat()) != FloatRange.EMPTY) {
|
||||||
return FloatRange.EMPTY.toString()
|
return FloatRange.EMPTY.toString()
|
||||||
}
|
}
|
||||||
if (LongRange(0, 0) != LongRange.EMPTY) {
|
if (LongRange(1, 0) != LongRange.EMPTY) {
|
||||||
return LongRange.EMPTY.toString()
|
return LongRange.EMPTY.toString()
|
||||||
}
|
}
|
||||||
if (DoubleRange(0.0, 0.0) != DoubleRange.EMPTY) {
|
if (DoubleRange(1.0, 0.0) != DoubleRange.EMPTY) {
|
||||||
return DoubleRange.EMPTY.toString()
|
return DoubleRange.EMPTY.toString()
|
||||||
}
|
}
|
||||||
return "OK"
|
return "OK"
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ fun box() : String {
|
|||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
val String?.indices : IntRange get() = IntRange(0, this!!.length)
|
val String?.indices : IntRange get() = 0..(this!!.length - 1)
|
||||||
@@ -16,7 +16,7 @@ fun box(): String {
|
|||||||
}
|
}
|
||||||
sb.append(";")
|
sb.append(";")
|
||||||
|
|
||||||
for (i in IntRange(0, 1)) {
|
for (i in IntRange(0, 0)) {
|
||||||
ap(i)
|
ap(i)
|
||||||
}
|
}
|
||||||
sb.append(";")
|
sb.append(";")
|
||||||
|
|||||||
@@ -26,6 +26,13 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GenerateRanges {
|
public class GenerateRanges {
|
||||||
|
private static String castIfNecessary(String what, String thisType, String otherType) {
|
||||||
|
if (thisType.equals("byte") && otherType.equals("char") || thisType.equals("char") && otherType.equals("short")) {
|
||||||
|
return "(" + otherType + ") " + what;
|
||||||
|
}
|
||||||
|
return what;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
PrintStream out = new PrintStream(new FileOutputStream("runtime/src/jet/runtime/Ranges.java"));
|
PrintStream out = new PrintStream(new FileOutputStream("runtime/src/jet/runtime/Ranges.java"));
|
||||||
try {
|
try {
|
||||||
@@ -68,37 +75,17 @@ public class GenerateRanges {
|
|||||||
resType = "ByteRange";
|
resType = "ByteRange";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resType.equals("FloatRange") || resType.equals("DoubleRange")) {
|
out.println(" public static " + resType + " rangeTo(" + t1 + " from, " + t2 + " to) {");
|
||||||
out.println(" public static " + resType + " rangeTo(" + t1 + " from, " + t2 + " to) {");
|
out.println(" return new " + resType + "("
|
||||||
out.println(" return new " + resType + "(from, to - from);");
|
+ castIfNecessary("from", t1, t2) + ", "
|
||||||
out.println(" }");
|
+ castIfNecessary("to", t2, t1) + ");");
|
||||||
out.println();
|
out.println(" }");
|
||||||
}
|
out.println();
|
||||||
else {
|
|
||||||
String castIfNecessary;
|
|
||||||
if (t1.equals("byte") && t2.equals("char") || t1.equals("char") && t2.equals("short")) {
|
|
||||||
castIfNecessary = "(" + t2 + ") ";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
castIfNecessary = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
out.println(" public static " + resType + " rangeTo(" + t1 + " from, " + t2 + " to) {");
|
|
||||||
out.println(" if (from > to) {");
|
|
||||||
out.println(" return " + resType + ".EMPTY;");
|
|
||||||
out.println(" }");
|
|
||||||
out.println(" else {");
|
|
||||||
out.println(" return new " + resType + "(" + castIfNecessary + "from, to - from + 1);");
|
|
||||||
out.println(" }");
|
|
||||||
out.println(" }");
|
|
||||||
out.println();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out.println(" public static IntRange arrayIndices(int length) {");
|
out.println(" public static IntRange arrayIndices(int length) {");
|
||||||
out.println(" return new IntRange(0, length);");
|
out.println(" return new IntRange(0, length - 1);");
|
||||||
out.println(" }");
|
out.println(" }");
|
||||||
out.println();
|
out.println();
|
||||||
|
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver;
|
|||||||
@AssertInvisibleInResolver
|
@AssertInvisibleInResolver
|
||||||
public final class ByteRange implements Range<Byte>, ByteIterable {
|
public final class ByteRange implements Range<Byte>, ByteIterable {
|
||||||
private final byte start;
|
private final byte start;
|
||||||
private final int count;
|
private final byte end;
|
||||||
|
|
||||||
public static final ByteRange EMPTY = new ByteRange((byte) 0,0);
|
public static final ByteRange EMPTY = new ByteRange((byte) 1, (byte) 0);
|
||||||
|
|
||||||
public ByteRange(byte startValue, int count) {
|
public ByteRange(byte start, byte end) {
|
||||||
this.start = startValue;
|
this.start = start;
|
||||||
this.count = count;
|
this.end = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -37,18 +37,11 @@ public final class ByteRange implements Range<Byte>, ByteIterable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Byte item) {
|
public boolean contains(Byte item) {
|
||||||
if (item == null) return false;
|
return start <= item && item <= end;
|
||||||
if (count >= 0) {
|
|
||||||
return item >= start && item < start + count;
|
|
||||||
}
|
|
||||||
return item <= start && item > start + count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(byte item) {
|
public boolean contains(byte item) {
|
||||||
if (count >= 0) {
|
return start <= item && item <= end;
|
||||||
return item >= start && item < start + count;
|
|
||||||
}
|
|
||||||
return item <= start && item > start + count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -61,13 +54,13 @@ public final class ByteRange implements Range<Byte>, ByteIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ByteRange range = (ByteRange) o;
|
ByteRange range = (ByteRange) o;
|
||||||
return count == range.count && start == range.start;
|
return end == range.end && start == range.start;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = (int) start;
|
int result = (int) start;
|
||||||
result = 31 * result + count;
|
result = 31 * result + end;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,11 +69,7 @@ public final class ByteRange implements Range<Byte>, ByteIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public byte getEnd() {
|
public byte getEnd() {
|
||||||
return (byte) (count < 0 ? start + count + 1: count == 0 ? 0 : start+count-1);
|
return end;
|
||||||
}
|
|
||||||
|
|
||||||
public int getSize() {
|
|
||||||
return count < 0 ? -count : count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver;
|
|||||||
@AssertInvisibleInResolver
|
@AssertInvisibleInResolver
|
||||||
public final class CharRange implements Range<Character>, CharIterable {
|
public final class CharRange implements Range<Character>, CharIterable {
|
||||||
private final char start;
|
private final char start;
|
||||||
private final int count;
|
private final char end;
|
||||||
|
|
||||||
public static final CharRange EMPTY = new CharRange((char) 0,0);
|
public static final CharRange EMPTY = new CharRange((char) 1, (char) 0);
|
||||||
|
|
||||||
public CharRange(char startValue, int count) {
|
public CharRange(char start, char end) {
|
||||||
this.start = startValue;
|
this.start = start;
|
||||||
this.count = count;
|
this.end = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -37,18 +37,11 @@ public final class CharRange implements Range<Character>, CharIterable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Character item) {
|
public boolean contains(Character item) {
|
||||||
if (item == null) return false;
|
return start <= item && item <= end;
|
||||||
if (count >= 0) {
|
|
||||||
return item >= start && item < start + count;
|
|
||||||
}
|
|
||||||
return item <= start && item > start + count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(char item) {
|
public boolean contains(char item) {
|
||||||
if (count >= 0) {
|
return start <= item && item <= end;
|
||||||
return item >= start && item < start + count;
|
|
||||||
}
|
|
||||||
return item <= start && item > start + count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -61,13 +54,13 @@ public final class CharRange implements Range<Character>, CharIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CharRange range = (CharRange) o;
|
CharRange range = (CharRange) o;
|
||||||
return count == range.count && start == range.start;
|
return end == range.end && start == range.start;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = (int) start;
|
int result = (int) start;
|
||||||
result = 31 * result + count;
|
result = 31 * result + end;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,11 +69,7 @@ public final class CharRange implements Range<Character>, CharIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public char getEnd() {
|
public char getEnd() {
|
||||||
return (char) (count < 0 ? start + count + 1: count == 0 ? 0 : start+count-1);
|
return end;
|
||||||
}
|
|
||||||
|
|
||||||
public int getSize() {
|
|
||||||
return count < 0 ? -count : count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver;
|
|||||||
@AssertInvisibleInResolver
|
@AssertInvisibleInResolver
|
||||||
public final class DoubleRange implements Range<Double> {
|
public final class DoubleRange implements Range<Double> {
|
||||||
private final double start;
|
private final double start;
|
||||||
private final double size;
|
private final double end;
|
||||||
|
|
||||||
public static final DoubleRange EMPTY = new DoubleRange(0, 0);
|
public static final DoubleRange EMPTY = new DoubleRange(1, 0);
|
||||||
|
|
||||||
public DoubleRange(double startValue, double size) {
|
public DoubleRange(double start, double end) {
|
||||||
this.start = startValue;
|
this.start = start;
|
||||||
this.size = size;
|
this.end = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -37,11 +37,7 @@ public final class DoubleRange implements Range<Double> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Double item) {
|
public boolean contains(Double item) {
|
||||||
if (item == null) return false;
|
return start <= item && item <= end;
|
||||||
if (size >= 0) {
|
|
||||||
return item >= start && item < start + size;
|
|
||||||
}
|
|
||||||
return item <= start && item > start + size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -55,7 +51,7 @@ public final class DoubleRange implements Range<Double> {
|
|||||||
|
|
||||||
DoubleRange range = (DoubleRange) o;
|
DoubleRange range = (DoubleRange) o;
|
||||||
|
|
||||||
return Double.compare(range.size, size) == 0 && Double.compare(range.start, start) == 0;
|
return Double.compare(range.end, end) == 0 && Double.compare(range.start, start) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -64,20 +60,16 @@ public final class DoubleRange implements Range<Double> {
|
|||||||
long temp;
|
long temp;
|
||||||
temp = start != +0.0d ? Double.doubleToLongBits(start) : 0L;
|
temp = start != +0.0d ? Double.doubleToLongBits(start) : 0L;
|
||||||
result = (int) (temp ^ (temp >>> 32));
|
result = (int) (temp ^ (temp >>> 32));
|
||||||
temp = size != +0.0d ? Double.doubleToLongBits(size) : 0L;
|
temp = end != +0.0d ? Double.doubleToLongBits(end) : 0L;
|
||||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getStart() {
|
public double getStart() {
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getEnd() {
|
public double getEnd() {
|
||||||
return size < 0 ? start + size: start + size;
|
return end;
|
||||||
}
|
|
||||||
|
|
||||||
public double getSize() {
|
|
||||||
return size < 0 ? -size : size;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver;
|
|||||||
@AssertInvisibleInResolver
|
@AssertInvisibleInResolver
|
||||||
public final class FloatRange implements Range<Float> {
|
public final class FloatRange implements Range<Float> {
|
||||||
private final float start;
|
private final float start;
|
||||||
private final float size;
|
private final float end;
|
||||||
|
|
||||||
public static final FloatRange EMPTY = new FloatRange(0, 0);
|
public static final FloatRange EMPTY = new FloatRange(1, 0);
|
||||||
|
|
||||||
public FloatRange(float startValue, float size) {
|
public FloatRange(float start, float end) {
|
||||||
this.start = startValue;
|
this.start = start;
|
||||||
this.size = size;
|
this.end = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -37,11 +37,7 @@ public final class FloatRange implements Range<Float> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Float item) {
|
public boolean contains(Float item) {
|
||||||
if (item == null) return false;
|
return start <= item && item <= end;
|
||||||
if (size >= 0) {
|
|
||||||
return item >= start && item < start + size;
|
|
||||||
}
|
|
||||||
return item <= start && item > start + size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -55,25 +51,21 @@ public final class FloatRange implements Range<Float> {
|
|||||||
|
|
||||||
FloatRange range = (FloatRange) o;
|
FloatRange range = (FloatRange) o;
|
||||||
|
|
||||||
return Float.compare(range.size, size) == 0 && Float.compare(range.start, start) == 0;
|
return Float.compare(range.end, end) == 0 && Float.compare(range.start, start) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = (start != +0.0f ? Float.floatToIntBits(start) : 0);
|
int result = (start != +0.0f ? Float.floatToIntBits(start) : 0);
|
||||||
result = 31 * result + (size != +0.0f ? Float.floatToIntBits(size) : 0);
|
result = 31 * result + (end != +0.0f ? Float.floatToIntBits(end) : 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getStart() {
|
public float getStart() {
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getEnd() {
|
public float getEnd() {
|
||||||
return size < 0 ? start + size: start + size;
|
return end;
|
||||||
}
|
|
||||||
|
|
||||||
public float getSize() {
|
|
||||||
return size < 0 ? -size : size;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver;
|
|||||||
@AssertInvisibleInResolver
|
@AssertInvisibleInResolver
|
||||||
public final class IntRange implements Range<Integer>, IntIterable {
|
public final class IntRange implements Range<Integer>, IntIterable {
|
||||||
private final int start;
|
private final int start;
|
||||||
private final int count;
|
private final int end;
|
||||||
|
|
||||||
public static final IntRange EMPTY = new IntRange(0, 0);
|
public static final IntRange EMPTY = new IntRange(1, 0);
|
||||||
|
|
||||||
public IntRange(int startValue, int count) {
|
public IntRange(int start, int end) {
|
||||||
this.start = startValue;
|
this.start = start;
|
||||||
this.count = count;
|
this.end = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -37,18 +37,11 @@ public final class IntRange implements Range<Integer>, IntIterable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Integer item) {
|
public boolean contains(Integer item) {
|
||||||
if (item == null) return false;
|
return start <= item && item <= end;
|
||||||
if (count >= 0) {
|
|
||||||
return item >= start && item < start + count;
|
|
||||||
}
|
|
||||||
return item <= start && item > start + count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(int item) {
|
public boolean contains(int item) {
|
||||||
if (count >= 0) {
|
return start <= item && item <= end;
|
||||||
return item >= start && item < start + count;
|
|
||||||
}
|
|
||||||
return item <= start && item > start + count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -61,13 +54,13 @@ public final class IntRange implements Range<Integer>, IntIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IntRange range = (IntRange) o;
|
IntRange range = (IntRange) o;
|
||||||
return count == range.count && start == range.start;
|
return end == range.end && start == range.start;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = start;
|
int result = start;
|
||||||
result = 31 * result + count;
|
result = 31 * result + end;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,11 +69,7 @@ public final class IntRange implements Range<Integer>, IntIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getEnd() {
|
public int getEnd() {
|
||||||
return count < 0 ? start + count + 1: count == 0 ? 0 : start+count-1;
|
return end;
|
||||||
}
|
|
||||||
|
|
||||||
public int getSize() {
|
|
||||||
return count < 0 ? -count : count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver;
|
|||||||
@AssertInvisibleInResolver
|
@AssertInvisibleInResolver
|
||||||
public final class LongRange implements Range<Long>, LongIterable {
|
public final class LongRange implements Range<Long>, LongIterable {
|
||||||
private final long start;
|
private final long start;
|
||||||
private final long count;
|
private final long end;
|
||||||
|
|
||||||
public static final LongRange EMPTY = new LongRange(0L,0L);
|
public static final LongRange EMPTY = new LongRange(1, 0);
|
||||||
|
|
||||||
public LongRange(long startValue, long count) {
|
public LongRange(long start, long end) {
|
||||||
this.start = startValue;
|
this.start = start;
|
||||||
this.count = count;
|
this.end = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -35,21 +35,13 @@ public final class LongRange implements Range<Long>, LongIterable {
|
|||||||
return getStart() + ".." + getEnd();
|
return getStart() + ".." + getEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Long item) {
|
public boolean contains(Long item) {
|
||||||
if (item == null) return false;
|
return start <= item && item <= end;
|
||||||
if (count >= 0) {
|
|
||||||
return item >= start && item < start + count;
|
|
||||||
}
|
|
||||||
return item <= start && item > start + count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(long item) {
|
public boolean contains(long item) {
|
||||||
if (count >= 0) {
|
return start <= item && item <= end;
|
||||||
return item >= start && item < start + count;
|
|
||||||
}
|
|
||||||
return item <= start && item > start + count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -62,13 +54,13 @@ public final class LongRange implements Range<Long>, LongIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LongRange range = (LongRange) o;
|
LongRange range = (LongRange) o;
|
||||||
return count == range.count && start == range.start;
|
return end == range.end && start == range.start;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = (int) (start ^ (start >>> 32));
|
int result = (int) (start ^ (start >>> 32));
|
||||||
result = 31 * result + (int) (count ^ (count >>> 32));
|
result = 31 * result + (int) (end ^ (end >>> 32));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,11 +69,7 @@ public final class LongRange implements Range<Long>, LongIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long getEnd() {
|
public long getEnd() {
|
||||||
return count < 0 ? start + count + 1: count == 0 ? 0 : start+count-1;
|
return end;
|
||||||
}
|
|
||||||
|
|
||||||
public long getSize() {
|
|
||||||
return count < 0 ? -count : count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ import org.jetbrains.jet.rt.annotation.AssertInvisibleInResolver;
|
|||||||
@AssertInvisibleInResolver
|
@AssertInvisibleInResolver
|
||||||
public final class ShortRange implements Range<Short>, ShortIterable {
|
public final class ShortRange implements Range<Short>, ShortIterable {
|
||||||
private final short start;
|
private final short start;
|
||||||
private final int count;
|
private final short end;
|
||||||
|
|
||||||
public static final ShortRange EMPTY = new ShortRange((short) 0,0);
|
public static final ShortRange EMPTY = new ShortRange((short) 1, (short) 0);
|
||||||
|
|
||||||
public ShortRange(short startValue, int count) {
|
public ShortRange(short start, short end) {
|
||||||
this.start = startValue;
|
this.start = start;
|
||||||
this.count = count;
|
this.end = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -37,18 +37,11 @@ public final class ShortRange implements Range<Short>, ShortIterable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Short item) {
|
public boolean contains(Short item) {
|
||||||
if (item == null) return false;
|
return start <= item && item <= end;
|
||||||
if (count >= 0) {
|
|
||||||
return item >= start && item < start + count;
|
|
||||||
}
|
|
||||||
return item <= start && item > start + count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(short item) {
|
public boolean contains(short item) {
|
||||||
if (count >= 0) {
|
return start <= item && item <= end;
|
||||||
return item >= start && item < start + count;
|
|
||||||
}
|
|
||||||
return item <= start && item > start + count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -61,13 +54,13 @@ public final class ShortRange implements Range<Short>, ShortIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ShortRange range = (ShortRange) o;
|
ShortRange range = (ShortRange) o;
|
||||||
return count == range.count && start == range.start;
|
return end == range.end && start == range.start;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = (int) start;
|
int result = (int) start;
|
||||||
result = 31 * result + count;
|
result = 31 * result + end;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,11 +69,7 @@ public final class ShortRange implements Range<Short>, ShortIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public short getEnd() {
|
public short getEnd() {
|
||||||
return (short) (count < 0 ? start + count + 1: count == 0 ? 0 : start+count-1);
|
return end;
|
||||||
}
|
|
||||||
|
|
||||||
public int getSize() {
|
|
||||||
return count < 0 ? -count : count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -22,328 +22,203 @@ import jet.*;
|
|||||||
/* This file is generated by org.jetbrains.jet.generators.runtime.GenerateRanges. DO NOT EDIT! */
|
/* This file is generated by org.jetbrains.jet.generators.runtime.GenerateRanges. DO NOT EDIT! */
|
||||||
public class Ranges {
|
public class Ranges {
|
||||||
public static ByteRange rangeTo(byte from, byte to) {
|
public static ByteRange rangeTo(byte from, byte to) {
|
||||||
if (from > to) {
|
return new ByteRange(from, to);
|
||||||
return ByteRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new ByteRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ShortRange rangeTo(byte from, short to) {
|
public static ShortRange rangeTo(byte from, short to) {
|
||||||
if (from > to) {
|
return new ShortRange(from, to);
|
||||||
return ShortRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new ShortRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange rangeTo(byte from, int to) {
|
public static IntRange rangeTo(byte from, int to) {
|
||||||
if (from > to) {
|
return new IntRange(from, to);
|
||||||
return IntRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new IntRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange rangeTo(byte from, long to) {
|
public static LongRange rangeTo(byte from, long to) {
|
||||||
if (from > to) {
|
return new LongRange(from, to);
|
||||||
return LongRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new LongRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FloatRange rangeTo(byte from, float to) {
|
public static FloatRange rangeTo(byte from, float to) {
|
||||||
return new FloatRange(from, to - from);
|
return new FloatRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DoubleRange rangeTo(byte from, double to) {
|
public static DoubleRange rangeTo(byte from, double to) {
|
||||||
return new DoubleRange(from, to - from);
|
return new DoubleRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CharRange rangeTo(byte from, char to) {
|
public static CharRange rangeTo(byte from, char to) {
|
||||||
if (from > to) {
|
return new CharRange((char) from, to);
|
||||||
return CharRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new CharRange((char) from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ShortRange rangeTo(short from, byte to) {
|
public static ShortRange rangeTo(short from, byte to) {
|
||||||
if (from > to) {
|
return new ShortRange(from, to);
|
||||||
return ShortRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new ShortRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ShortRange rangeTo(short from, short to) {
|
public static ShortRange rangeTo(short from, short to) {
|
||||||
if (from > to) {
|
return new ShortRange(from, to);
|
||||||
return ShortRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new ShortRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange rangeTo(short from, int to) {
|
public static IntRange rangeTo(short from, int to) {
|
||||||
if (from > to) {
|
return new IntRange(from, to);
|
||||||
return IntRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new IntRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange rangeTo(short from, long to) {
|
public static LongRange rangeTo(short from, long to) {
|
||||||
if (from > to) {
|
return new LongRange(from, to);
|
||||||
return LongRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new LongRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FloatRange rangeTo(short from, float to) {
|
public static FloatRange rangeTo(short from, float to) {
|
||||||
return new FloatRange(from, to - from);
|
return new FloatRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DoubleRange rangeTo(short from, double to) {
|
public static DoubleRange rangeTo(short from, double to) {
|
||||||
return new DoubleRange(from, to - from);
|
return new DoubleRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ShortRange rangeTo(short from, char to) {
|
public static ShortRange rangeTo(short from, char to) {
|
||||||
if (from > to) {
|
return new ShortRange(from, (short) to);
|
||||||
return ShortRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new ShortRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange rangeTo(int from, byte to) {
|
public static IntRange rangeTo(int from, byte to) {
|
||||||
if (from > to) {
|
return new IntRange(from, to);
|
||||||
return IntRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new IntRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange rangeTo(int from, short to) {
|
public static IntRange rangeTo(int from, short to) {
|
||||||
if (from > to) {
|
return new IntRange(from, to);
|
||||||
return IntRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new IntRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange rangeTo(int from, int to) {
|
public static IntRange rangeTo(int from, int to) {
|
||||||
if (from > to) {
|
return new IntRange(from, to);
|
||||||
return IntRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new IntRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange rangeTo(int from, long to) {
|
public static LongRange rangeTo(int from, long to) {
|
||||||
if (from > to) {
|
return new LongRange(from, to);
|
||||||
return LongRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new LongRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FloatRange rangeTo(int from, float to) {
|
public static FloatRange rangeTo(int from, float to) {
|
||||||
return new FloatRange(from, to - from);
|
return new FloatRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DoubleRange rangeTo(int from, double to) {
|
public static DoubleRange rangeTo(int from, double to) {
|
||||||
return new DoubleRange(from, to - from);
|
return new DoubleRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange rangeTo(int from, char to) {
|
public static IntRange rangeTo(int from, char to) {
|
||||||
if (from > to) {
|
return new IntRange(from, to);
|
||||||
return IntRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new IntRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange rangeTo(long from, byte to) {
|
public static LongRange rangeTo(long from, byte to) {
|
||||||
if (from > to) {
|
return new LongRange(from, to);
|
||||||
return LongRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new LongRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange rangeTo(long from, short to) {
|
public static LongRange rangeTo(long from, short to) {
|
||||||
if (from > to) {
|
return new LongRange(from, to);
|
||||||
return LongRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new LongRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange rangeTo(long from, int to) {
|
public static LongRange rangeTo(long from, int to) {
|
||||||
if (from > to) {
|
return new LongRange(from, to);
|
||||||
return LongRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new LongRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange rangeTo(long from, long to) {
|
public static LongRange rangeTo(long from, long to) {
|
||||||
if (from > to) {
|
return new LongRange(from, to);
|
||||||
return LongRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new LongRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FloatRange rangeTo(long from, float to) {
|
public static FloatRange rangeTo(long from, float to) {
|
||||||
return new FloatRange(from, to - from);
|
return new FloatRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DoubleRange rangeTo(long from, double to) {
|
public static DoubleRange rangeTo(long from, double to) {
|
||||||
return new DoubleRange(from, to - from);
|
return new DoubleRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange rangeTo(long from, char to) {
|
public static LongRange rangeTo(long from, char to) {
|
||||||
if (from > to) {
|
return new LongRange(from, to);
|
||||||
return LongRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new LongRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FloatRange rangeTo(float from, byte to) {
|
public static FloatRange rangeTo(float from, byte to) {
|
||||||
return new FloatRange(from, to - from);
|
return new FloatRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FloatRange rangeTo(float from, short to) {
|
public static FloatRange rangeTo(float from, short to) {
|
||||||
return new FloatRange(from, to - from);
|
return new FloatRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FloatRange rangeTo(float from, int to) {
|
public static FloatRange rangeTo(float from, int to) {
|
||||||
return new FloatRange(from, to - from);
|
return new FloatRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FloatRange rangeTo(float from, long to) {
|
public static FloatRange rangeTo(float from, long to) {
|
||||||
return new FloatRange(from, to - from);
|
return new FloatRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FloatRange rangeTo(float from, float to) {
|
public static FloatRange rangeTo(float from, float to) {
|
||||||
return new FloatRange(from, to - from);
|
return new FloatRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DoubleRange rangeTo(float from, double to) {
|
public static DoubleRange rangeTo(float from, double to) {
|
||||||
return new DoubleRange(from, to - from);
|
return new DoubleRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FloatRange rangeTo(float from, char to) {
|
public static FloatRange rangeTo(float from, char to) {
|
||||||
return new FloatRange(from, to - from);
|
return new FloatRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DoubleRange rangeTo(double from, byte to) {
|
public static DoubleRange rangeTo(double from, byte to) {
|
||||||
return new DoubleRange(from, to - from);
|
return new DoubleRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DoubleRange rangeTo(double from, short to) {
|
public static DoubleRange rangeTo(double from, short to) {
|
||||||
return new DoubleRange(from, to - from);
|
return new DoubleRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DoubleRange rangeTo(double from, int to) {
|
public static DoubleRange rangeTo(double from, int to) {
|
||||||
return new DoubleRange(from, to - from);
|
return new DoubleRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DoubleRange rangeTo(double from, long to) {
|
public static DoubleRange rangeTo(double from, long to) {
|
||||||
return new DoubleRange(from, to - from);
|
return new DoubleRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DoubleRange rangeTo(double from, float to) {
|
public static DoubleRange rangeTo(double from, float to) {
|
||||||
return new DoubleRange(from, to - from);
|
return new DoubleRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DoubleRange rangeTo(double from, double to) {
|
public static DoubleRange rangeTo(double from, double to) {
|
||||||
return new DoubleRange(from, to - from);
|
return new DoubleRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DoubleRange rangeTo(double from, char to) {
|
public static DoubleRange rangeTo(double from, char to) {
|
||||||
return new DoubleRange(from, to - from);
|
return new DoubleRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CharRange rangeTo(char from, byte to) {
|
public static CharRange rangeTo(char from, byte to) {
|
||||||
if (from > to) {
|
return new CharRange(from, (char) to);
|
||||||
return CharRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new CharRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ShortRange rangeTo(char from, short to) {
|
public static ShortRange rangeTo(char from, short to) {
|
||||||
if (from > to) {
|
return new ShortRange((short) from, to);
|
||||||
return ShortRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new ShortRange((short) from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange rangeTo(char from, int to) {
|
public static IntRange rangeTo(char from, int to) {
|
||||||
if (from > to) {
|
return new IntRange(from, to);
|
||||||
return IntRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new IntRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange rangeTo(char from, long to) {
|
public static LongRange rangeTo(char from, long to) {
|
||||||
if (from > to) {
|
return new LongRange(from, to);
|
||||||
return LongRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new LongRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FloatRange rangeTo(char from, float to) {
|
public static FloatRange rangeTo(char from, float to) {
|
||||||
return new FloatRange(from, to - from);
|
return new FloatRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DoubleRange rangeTo(char from, double to) {
|
public static DoubleRange rangeTo(char from, double to) {
|
||||||
return new DoubleRange(from, to - from);
|
return new DoubleRange(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CharRange rangeTo(char from, char to) {
|
public static CharRange rangeTo(char from, char to) {
|
||||||
if (from > to) {
|
return new CharRange(from, to);
|
||||||
return CharRange.EMPTY;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new CharRange(from, to - from + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange arrayIndices(int length) {
|
public static IntRange arrayIndices(int length) {
|
||||||
return new IntRange(0, length);
|
return new IntRange(0, length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Ranges() {}
|
private Ranges() {}
|
||||||
|
|||||||
Reference in New Issue
Block a user