vigna / fastutil

fastutil extends the Java™ Collections Framework by providing type-specific maps, sets, lists and queues.
Apache License 2.0
1.78k stars 196 forks source link

Fast subList for ImmutableList #223

Closed techsy730 closed 3 years ago

techsy730 commented 3 years ago

Right now ImmutableList will give the standard AbstractList's subList. While not terrible, it certainly could be much better. In particular, it would be nice to have

The former wouldn't be too hard, the latter however may require some extra work. Right now, the assumption that the whole array of ImmutableList is the entire list contents, no slack. However, for a subList, we would want a view of a subset of the array. That would require overriding quite a few methods if it were to extend from ImmutableList, as the assumption that the whole array is the contents no longer holds.

Possibly, we can just document in the Javadoc that the returned subList is immutable, but not actually extend from it, and maybe put a note that in the future it may be declared an ImmutableList (and thus you shouldn't rely on the return type if you do extend this class)