Issue found out in the http://forum.processing.org/two/discussion/2473/out-of-bounds-intlist-index-returns-zero thread.
IntList il = new IntList();
println(il.get(3));
println(il.get(10));
exit();
The first access returns zero, the second one issues an ArrayIndexOutOfBoundsException.
I suggest that these structures check the given index against the size() of the data and generate themselves an IndexOutOfBoundsException, or return consistently zero in this case, if you want to avoid to throw exceptions.
The exception is probably better, as it is the behavior of ArrayList, officially part of Processing.
Issue found out in the http://forum.processing.org/two/discussion/2473/out-of-bounds-intlist-index-returns-zero thread.
The first access returns zero, the second one issues an ArrayIndexOutOfBoundsException.
I suggest that these structures check the given index against the size() of the data and generate themselves an IndexOutOfBoundsException, or return consistently zero in this case, if you want to avoid to throw exceptions.
The exception is probably better, as it is the behavior of ArrayList, officially part of Processing.