Fix bug in ImmutableSubList iterator

listIterator() on a sublist needs to correct its index to add "from" to it.
This commit is contained in:
goldfeder 2023-03-13 12:10:14 +02:00 committed by GitHub
parent 3edb5bcda8
commit b0f7543eca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -535,10 +535,10 @@ public class IMMUTABLE_LIST KEY_GENERIC extends LISTS.ImmutableListBase KEY_GENE
@Override
public KEY_LIST_ITERATOR KEY_GENERIC listIterator(final int index) {
ensureIndex(index);
ensureRestrictedIndex(index + from);
return new KEY_LIST_ITERATOR KEY_GENERIC() {
int pos = index;
int pos = index + from;
@Override
public boolean hasNext() { return pos < to; }
@ -851,4 +851,4 @@ public class IMMUTABLE_LIST KEY_GENERIC extends LISTS.ImmutableListBase KEY_GENE
#endif
}
#undef _EMPTY_ARRAY
#undef _EMPTY_ARRAY