diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-10-21 23:36:28 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-10-22 01:41:20 +0800 |
| commit | 62045c9cc0416557e6b57b6f4101b98a0da02dde (patch) | |
| tree | 7361edee07b0fae370b0006de5c5e2b219a67408 /api/src/main/java/me | |
| parent | 843a29c5fcf8d20f7073438d9fbed7039dead719 (diff) | |
| download | RoughlyEnoughItems-62045c9cc0416557e6b57b6f4101b98a0da02dde.tar.gz RoughlyEnoughItems-62045c9cc0416557e6b57b6f4101b98a0da02dde.tar.bz2 RoughlyEnoughItems-62045c9cc0416557e6b57b6f4101b98a0da02dde.zip | |
Fix most of the issues in #643
Diffstat (limited to 'api/src/main/java/me')
| -rw-r--r-- | api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java b/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java index 97934437d..09511ac6f 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/util/CollectionUtils.java @@ -306,7 +306,20 @@ public class CollectionUtils { @Override public List<T> next() { int cursor = i++ * size; - return list.subList(cursor, cursor + Math.min(list.size() - cursor, size)); + int realSize = Math.min(list.size() - cursor, size); + return new AbstractList<T>() { + @Override + public T get(int index) { + if (index < 0 || index >= realSize) + throw new IndexOutOfBoundsException(String.format("Index %s out of bounds for length %s", index, realSize)); + return list.get(cursor + index); + } + + @Override + public int size() { + return realSize; + } + }; } }; } |
