4 ms·
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 pare
by raffi 18y ago
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/sleep/engine/types/MyLinkedList.java http://svn.berlios.de/viewcvs/*checkout*/sleep/sleep/src/sle...