Fix bug in Arrays.binarySearch
@@ -977,6 +977,9 @@ public class TArrays extends TObject {
if (fromIndex > toIndex) {
throw new TIllegalArgumentException();
}
+ if (fromIndex == toIndex) {
+ return -1;
+ }
int l = fromIndex;
int u = toIndex - 1;
while (true) {
@@ -1006,6 +1009,9 @@ public class TArrays extends TObject {
if (fromIndex > toIndex) {
throw new TIllegalArgumentException();
}
+ if (fromIndex == toIndex) {
+ return -1;
+ }
int l = fromIndex;
int u = toIndex - 1;
while (true) {
@@ -1035,6 +1041,9 @@ public class TArrays extends TObject {
if (fromIndex > toIndex) {
throw new TIllegalArgumentException();
}
+ if (fromIndex == toIndex) {
+ return -1;
+ }
int l = fromIndex;
int u = toIndex - 1;
while (true) {
@@ -1064,6 +1073,9 @@ public class TArrays extends TObject {
if (fromIndex > toIndex) {
throw new TIllegalArgumentException();
}
+ if (fromIndex == toIndex) {
+ return -1;
+ }
int l = fromIndex;
int u = toIndex - 1;
while (true) {
@@ -1093,6 +1105,9 @@ public class TArrays extends TObject {
if (fromIndex > toIndex) {
throw new TIllegalArgumentException();
}
+ if (fromIndex == toIndex) {
+ return -1;
+ }
int l = fromIndex;
int u = toIndex - 1;
while (true) {
@@ -1122,6 +1137,9 @@ public class TArrays extends TObject {
if (fromIndex > toIndex) {
throw new TIllegalArgumentException();
}
+ if (fromIndex == toIndex) {
+ return -1;
+ }
int l = fromIndex;
int u = toIndex - 1;
while (true) {
@@ -1151,6 +1169,9 @@ public class TArrays extends TObject {
if (fromIndex > toIndex) {
throw new TIllegalArgumentException();
}
+ if (fromIndex == toIndex) {
+ return -1;
+ }
int l = fromIndex;
int u = toIndex - 1;
while (true) {
@@ -1188,6 +1209,9 @@ public class TArrays extends TObject {
if (fromIndex > toIndex) {
throw new TIllegalArgumentException();
}
+ if (fromIndex == toIndex) {
+ return -1;
+ }
int l = fromIndex;
int u = toIndex - 1;
while (true) {
