fixing stupid bug introduced in previous commit

simplification of api
This commit is contained in:
Alex Tkachman
2012-01-06 14:22:02 +02:00
parent 1d2e237312
commit 22afbed909
8 changed files with 50 additions and 121 deletions
-17
View File
@@ -11,14 +11,6 @@ public final class ByteRange implements Range<Byte>, ByteIterable, JetObject {
this.count = count;
}
public ByteRange(byte startValue, int count, boolean reversed) {
this(startValue, reversed ? -count : count);
}
public ByteRange(byte startValue, int count, boolean reversed, int defaultMask) {
this(startValue, reversed ? -count : count, (defaultMask & 4) == 0);
}
@Override
public boolean contains(Byte item) {
if (item == null) return false;
@@ -71,15 +63,6 @@ public final class ByteRange implements Range<Byte>, ByteIterable, JetObject {
return new ByteRange((byte) 0, length);
}
public static ByteRange rangeTo(byte from, byte to) {
if(from > to) {
return new ByteRange(to, from-to+1, true);
}
else {
return new ByteRange(from, to-from+1);
}
}
private static class MyIterator extends ByteIterator {
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false);
-17
View File
@@ -11,14 +11,6 @@ public final class CharRange implements Range<Character>, CharIterable, JetObjec
this.count = count;
}
public CharRange(char startValue, int count, boolean reversed) {
this(startValue, reversed ? -count : count);
}
public CharRange(char startValue, int count, boolean reversed, int defaultMask) {
this(startValue, reversed ? -count : count, (defaultMask & 4) == 0);
}
@Override
public boolean contains(Character item) {
if (item == null) return false;
@@ -71,15 +63,6 @@ public final class CharRange implements Range<Character>, CharIterable, JetObjec
return new CharRange((char) 0, length);
}
public static CharRange rangeTo(char from, char to) {
if(from > to) {
return new CharRange(to, from-to+1, true);
}
else {
return new CharRange(from, to-from+1);
}
}
private static class MyIterator extends CharIterator {
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false);
+9 -19
View File
@@ -11,14 +11,6 @@ public final class IntRange implements Range<Integer>, IntIterable, JetObject {
this.count = count;
}
public IntRange(int startValue, int count, boolean reversed) {
this(startValue, reversed ? -count : count);
}
public IntRange(int startValue, int count, boolean reversed, int defaultMask) {
this(startValue, reversed ? -count : count, (defaultMask & 4) == 0);
}
@Override
public boolean contains(Integer item) {
if (item == null) return false;
@@ -71,15 +63,6 @@ public final class IntRange implements Range<Integer>, IntIterable, JetObject {
return new IntRange(0, length);
}
public static IntRange rangeTo(int from, int to) {
if(from > to) {
return new IntRange(to, from-to+1, true);
}
else {
return new IntRange(from, to-from+1);
}
}
private static class MyIterator extends IntIterator {
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false);
@@ -92,8 +75,15 @@ public final class IntRange implements Range<Integer>, IntIterable, JetObject {
public MyIterator(int startValue, int count, int step) {
cur = startValue;
this.step = step;
reversed = count < 0;
this.count = reversed ? -count : count;
if(count < 0) {
reversed = count < 0;
count = -count;
startValue += count;
}
else {
reversed = false;
}
this.count = count;
}
@Override
-8
View File
@@ -11,14 +11,6 @@ public final class LongRange implements Range<Long>, LongIterable, JetObject {
this.count = count;
}
public LongRange(long startValue, long count, boolean reversed) {
this(startValue, reversed ? -count : count);
}
public LongRange(int startValue, int count, boolean reversed, int defaultMask) {
this(startValue, reversed ? -count : count, (defaultMask & 4) == 0);
}
public LongIterator step(long step) {
return new MyIterator(start, count, step);
}
-17
View File
@@ -11,14 +11,6 @@ public final class ShortRange implements Range<Short>, ShortIterable, JetObject
this.count = count;
}
public ShortRange(short startValue, int count, boolean reversed) {
this(startValue, reversed ? -count : count);
}
public ShortRange(short startValue, int count, boolean reversed, int defaultMask) {
this(startValue, reversed ? -count : count, (defaultMask & 4) == 0);
}
public ShortIterator step(int step) {
return new MyIterator(start, count, step);
}
@@ -71,15 +63,6 @@ public final class ShortRange implements Range<Short>, ShortIterable, JetObject
return new ShortRange((byte) 0, length);
}
public static ShortRange rangeTo(short from, short to) {
if(from > to) {
return new ShortRange(to, from-to+1, true);
}
else {
return new ShortRange(from, to-from+1);
}
}
private static class MyIterator extends ShortIterator {
private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false);
+26 -26
View File
@@ -14,7 +14,7 @@ public class Ranges {
public static ByteRange rangeTo(byte from, byte to) {
if(from > to) {
return new ByteRange(to, from-to+1, true);
return new ByteRange(from, to-from-1);
}
else {
return new ByteRange(from, to-from+1);
@@ -23,7 +23,7 @@ public class Ranges {
public static ShortRange rangeTo(byte from, short to) {
if(from > to) {
return new ShortRange(to, from-to+1, true);
return new ShortRange(from, to-from-1);
}
else {
return new ShortRange(from, to-from+1);
@@ -32,7 +32,7 @@ public class Ranges {
public static IntRange rangeTo(byte from, int to) {
if(from > to) {
return new IntRange(to, from-to+1, true);
return new IntRange(from, to-from-1);
}
else {
return new IntRange(from, to-from+1);
@@ -41,7 +41,7 @@ public class Ranges {
public static LongRange rangeTo(byte from, long to) {
if(from > to) {
return new LongRange(to, from-to+1, true);
return new LongRange(from, to-from-1);
}
else {
return new LongRange(from, to-from+1);
@@ -50,7 +50,7 @@ public class Ranges {
public static CharRange rangeTo(byte from, char to) {
if(from > to) {
return new CharRange(to, from-to+1, true);
return new CharRange((char) from, to-from-1);
}
else {
return new CharRange((char) from, to-from+1);
@@ -59,7 +59,7 @@ public class Ranges {
public static ShortRange rangeTo(short from, byte to) {
if(from > to) {
return new ShortRange(to, from-to+1, true);
return new ShortRange(from, to-from-1);
}
else {
return new ShortRange(from, to-from+1);
@@ -68,7 +68,7 @@ public class Ranges {
public static ShortRange rangeTo(short from, short to) {
if(from > to) {
return new ShortRange(to, from-to+1, true);
return new ShortRange(from, to-from-1);
}
else {
return new ShortRange(from, to-from+1);
@@ -77,7 +77,7 @@ public class Ranges {
public static IntRange rangeTo(short from, int to) {
if(from > to) {
return new IntRange(to, from-to+1, true);
return new IntRange(from, to-from-1);
}
else {
return new IntRange(from, to-from+1);
@@ -86,7 +86,7 @@ public class Ranges {
public static LongRange rangeTo(short from, long to) {
if(from > to) {
return new LongRange(to, from-to+1, true);
return new LongRange(from, to-from-1);
}
else {
return new LongRange(from, to-from+1);
@@ -95,7 +95,7 @@ public class Ranges {
public static ShortRange rangeTo(short from, char to) {
if(from > to) {
return new ShortRange((short) to, from-to+1, true);
return new ShortRange(from, to-from-1);
}
else {
return new ShortRange(from, to-from+1);
@@ -104,7 +104,7 @@ public class Ranges {
public static IntRange rangeTo(int from, byte to) {
if(from > to) {
return new IntRange(to, from-to+1, true);
return new IntRange(from, to-from-1);
}
else {
return new IntRange(from, to-from+1);
@@ -113,7 +113,7 @@ public class Ranges {
public static IntRange rangeTo(int from, short to) {
if(from > to) {
return new IntRange(to, from-to+1, true);
return new IntRange(from, to-from-1);
}
else {
return new IntRange(from, to-from+1);
@@ -122,7 +122,7 @@ public class Ranges {
public static IntRange rangeTo(int from, int to) {
if(from > to) {
return new IntRange(to, from-to+1, true);
return new IntRange(from, to-from-1);
}
else {
return new IntRange(from, to-from+1);
@@ -131,7 +131,7 @@ public class Ranges {
public static LongRange rangeTo(int from, long to) {
if(from > to) {
return new LongRange(to, from-to+1, true);
return new LongRange(from, to-from-1);
}
else {
return new LongRange(from, to-from+1);
@@ -140,7 +140,7 @@ public class Ranges {
public static IntRange rangeTo(int from, char to) {
if(from > to) {
return new IntRange(to, from-to+1, true);
return new IntRange(from, to-from-1);
}
else {
return new IntRange(from, to-from+1);
@@ -149,7 +149,7 @@ public class Ranges {
public static LongRange rangeTo(long from, byte to) {
if(from > to) {
return new LongRange(to, from-to+1, true);
return new LongRange(from, to-from-1);
}
else {
return new LongRange(from, to-from+1);
@@ -158,7 +158,7 @@ public class Ranges {
public static LongRange rangeTo(long from, short to) {
if(from > to) {
return new LongRange(to, from-to+1, true);
return new LongRange(from, to-from-1);
}
else {
return new LongRange(from, to-from+1);
@@ -167,7 +167,7 @@ public class Ranges {
public static LongRange rangeTo(long from, int to) {
if(from > to) {
return new LongRange(to, from-to+1, true);
return new LongRange(from, to-from-1);
}
else {
return new LongRange(from, to-from+1);
@@ -176,7 +176,7 @@ public class Ranges {
public static LongRange rangeTo(long from, long to) {
if(from > to) {
return new LongRange(to, from-to+1, true);
return new LongRange(from, to-from-1);
}
else {
return new LongRange(from, to-from+1);
@@ -185,7 +185,7 @@ public class Ranges {
public static LongRange rangeTo(long from, char to) {
if(from > to) {
return new LongRange(to, from-to+1, true);
return new LongRange(from, to-from-1);
}
else {
return new LongRange(from, to-from+1);
@@ -194,7 +194,7 @@ public class Ranges {
public static CharRange rangeTo(char from, byte to) {
if(from > to) {
return new CharRange((char) to, from-to+1, true);
return new CharRange(from, to-from-1);
}
else {
return new CharRange(from, to-from+1);
@@ -203,7 +203,7 @@ public class Ranges {
public static ShortRange rangeTo(char from, short to) {
if(from > to) {
return new ShortRange(to, from-to+1, true);
return new ShortRange((short) from, to-from-1);
}
else {
return new ShortRange((short) from, to-from+1);
@@ -212,7 +212,7 @@ public class Ranges {
public static IntRange rangeTo(char from, int to) {
if(from > to) {
return new IntRange(to, from-to+1, true);
return new IntRange(from, to-from-1);
}
else {
return new IntRange(from, to-from+1);
@@ -221,7 +221,7 @@ public class Ranges {
public static LongRange rangeTo(char from, long to) {
if(from > to) {
return new LongRange(to, from-to+1, true);
return new LongRange(from, to-from-1);
}
else {
return new LongRange(from, to-from+1);
@@ -230,7 +230,7 @@ public class Ranges {
public static CharRange rangeTo(char from, char to) {
if(from > to) {
return new CharRange(to, from-to+1, true);
return new CharRange(from, to-from-1);
}
else {
return new CharRange(from, to-from+1);
@@ -266,7 +266,7 @@ public class Ranges {
System.out.println("\npublic static " + resType + " rangeTo(" + t1 + " from, " + t2 + " to) {" +
"\n if(from > to) {\n" +
" return new " + resType + "(to, from-to+1, true);\n" +
" return new " + resType + "(from, to-from-1);\n" +
" }\n" +
" else {\n" +
" return new " + resType + "(from, to-from+1);\n" +