KT-944 iterations over empty ranges

This commit is contained in:
Alex Tkachman
2012-01-10 09:33:54 +02:00
parent ed58ca219b
commit a0134fb0f2
9 changed files with 43 additions and 1 deletions
+4
View File
@@ -30,6 +30,10 @@ public final class ByteRange implements Range<Byte>, ByteIterable, JetObject {
return start;
}
public byte getIteratorStart () {
return count == 0 ? 1 : start;
}
public byte getEnd() {
return (byte) (count < 0 ? start + count + 1: count == 0 ? 0 : start+count-1);
}
+4
View File
@@ -30,6 +30,10 @@ public final class CharRange implements Range<Character>, CharIterable, JetObjec
return start;
}
public char getIteratorStart () {
return count == 0 ? 1 : start;
}
public char getEnd() {
return (char) (count < 0 ? start + count + 1: count == 0 ? 0 : start+count-1);
}
+4
View File
@@ -33,6 +33,10 @@ public final class IntRange implements Range<Integer>, IntIterable, JetObject {
return count < 0;
}
public int getIteratorStart () {
return count == 0 ? 1 : start;
}
public int getStart() {
return start;
}
+4
View File
@@ -37,6 +37,10 @@ public final class LongRange implements Range<Long>, LongIterable, JetObject {
return start;
}
public long getIteratorStart () {
return count == 0 ? 1 : start;
}
public long getEnd() {
return count < 0 ? start + count + 1: count == 0 ? 0 : start+count-1;
}
+4
View File
@@ -37,6 +37,10 @@ public final class ShortRange implements Range<Short>, ShortIterable, JetObject
return start;
}
public int getIteratorStart () {
return count == 0 ? 1 : start;
}
public short getEnd() {
return (short) (count < 0 ? start + count + 1: count == 0 ? 0 : start+count-1);
}