KT-2416 fix contains for ranges with primitive parameters

This commit is contained in:
Alex Tkachman
2012-08-03 09:15:53 +03:00
parent 8ba9e9f51b
commit 0e4a8660fd
9 changed files with 79 additions and 17 deletions
+7
View File
@@ -39,6 +39,13 @@ public final class ByteRange implements Range<Byte>, ByteIterable {
return item <= start && item > start + count;
}
public boolean contains(byte item) {
if (count >= 0) {
return item >= start && item < start + count;
}
return item <= start && item > start + count;
}
@Override
public boolean equals(Object o) {
if (this == o) {
+7
View File
@@ -39,6 +39,13 @@ public final class CharRange implements Range<Character>, CharIterable {
return item <= start && item > start + count;
}
public boolean contains(char item) {
if (count >= 0) {
return item >= start && item < start + count;
}
return item <= start && item > start + count;
}
@Override
public boolean equals(Object o) {
if (this == o) {
+7
View File
@@ -48,6 +48,13 @@ public final class IntRange implements Range<Integer>, IntIterable {
return item <= start && item > start + count;
}
public boolean contains(int item) {
if (count >= 0) {
return item >= start && item < start + count;
}
return item <= start && item > start + count;
}
@Override
public boolean equals(Object o) {
if (this == o) {
+7
View File
@@ -46,6 +46,13 @@ public final class LongRange implements Range<Long>, LongIterable {
return item <= start && item > start + count;
}
public boolean contains(long item) {
if (count >= 0) {
return item >= start && item < start + count;
}
return item <= start && item > start + count;
}
@Override
public boolean equals(Object o) {
if (this == o) {
+7
View File
@@ -46,6 +46,13 @@ public final class ShortRange implements Range<Short>, ShortIterable {
return item <= start && item > start + count;
}
public boolean contains(short item) {
if (count >= 0) {
return item >= start && item < start + count;
}
return item <= start && item > start + count;
}
@Override
public boolean equals(Object o) {
if (this == o) {