diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-10-21 23:36:28 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-10-21 23:36:28 +0800 |
| commit | d18620eadb0c6201ba8e99711036bc102960cd14 (patch) | |
| tree | 52ef9fe2af23a5f52d7fcf428be985cf254f2554 /api/src/main/java | |
| parent | a2cbe3b62c01088edd7427ff75886d6996c85404 (diff) | |
| download | RoughlyEnoughItems-d18620eadb0c6201ba8e99711036bc102960cd14.tar.gz RoughlyEnoughItems-d18620eadb0c6201ba8e99711036bc102960cd14.tar.bz2 RoughlyEnoughItems-d18620eadb0c6201ba8e99711036bc102960cd14.zip | |
Fix most of the issues in #643
Diffstat (limited to 'api/src/main/java')
| -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; + } + }; } }; } |
