Merge pull request #3252 from JohnSimith/v6-dev

fix 修复数组下标越界的问题
This commit is contained in:
Golden Looly 2023-08-09 13:57:07 +08:00 committed by GitHub
commit 40118afda9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -550,12 +550,14 @@ public class ArrayWrapper<A, E> implements Wrapper<A>, Iterable<E> {
} }
int compare; int compare;
for (int i = 0; i < this.length; i++) { for (int i = 0; i < this.length - 1; i++) {
compare = comparator.compare(get(i), get(i + 1)); compare = comparator.compare(get(i), get(i + 1));
if ((isDESC && compare < 0) ||
(!isDESC && compare > 0)) {
// 反序前一个小于后一个则返回错 // 反序前一个小于后一个则返回错
if (isDESC && compare < 0) {
return false;
}
// 正序前一个大于后一个则返回错 // 正序前一个大于后一个则返回错
if(!isDESC && compare > 0){
return false; return false;
} }
} }