fastutil icon indicating copy to clipboard operation
fastutil copied to clipboard

ArrayIndexOutOfBoundsException in the iterator of subList of the IntImmutableList

Open MartinTunzer-TomTom opened this issue 1 year ago • 1 comments

Version 8.5.12 How to reproduce:

IntList list = new IntArrayList();
list.add(1);
list.add(2);
list.add(3);

list = new IntImmutableList(list);

IntList subList = list.subList(1, 3);

for (int i : subList) {
    System.out.println("i = " + i);
}

gives:

i = 2
i = 3
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 3 out of bounds for length 3
	at it.unimi.dsi.fastutil.ints.IntImmutableList$ImmutableSubList$1.nextInt(IntImmutableList.java:483)
	at it.unimi.dsi.fastutil.ints.IntIterator.next(IntIterator.java:46)
	at it.unimi.dsi.fastutil.ints.IntListIterator.next(IntListIterator.java:103)
	at it.unimi.dsi.fastutil.ints.IntListIterator.next(IntListIterator.java:31)

MartinTunzer-TomTom avatar Jun 07 '24 13:06 MartinTunzer-TomTom

This should be fixed in the GitHub code. Can you check whether this is the case ? I'm gonna do a release ASAP.

vigna avatar Jun 10 '24 07:06 vigna