

Java subList Gotcha - baha_man
http://teddziuba.com/2008/09/java-sublist-gotcha.html

======
raffi
I got bit by this when writing Sleep. I had to write my own LinkedList class
that implemented a sublist as a head/tail pointer sharing the contents of the
parent list. Creation of the sublist is O(n) but other operations are O(m)
based on the sublist rather than O(n) based on the parent list. And of course
functions that recursively create sublists and iterate through them do not
blow up unexpectedly.

The code is open source and compatible with LinkedList.java. The differences
are: the description passed to any ConcurrentModificationException and
sublists are serializable. Deserialized sublists are merely copies of the
sublist and are unable to affect the parent list.

[http://svn.berlios.de/viewcvs/*checkout*/sleep/sleep/src/sle...](http://svn.berlios.de/viewcvs/*checkout*/sleep/sleep/src/sleep/engine/types/MyLinkedList.java)

