"By doing:
original.get(3).value = 0;
you changed the last element internally, so the SortedList has no way to know that something changed and will result in (LIVE) SortedList that is actually not sorted."
I think that's not the point: fully agreed that mutating elements under the feet of the list isn't a good idea (no way for the list the handle), the point is setting the mutated element throws. From the perspective of an observer (like a sorted list) of the original list, it's just a replaced element and the observer must cope with it
original.get(3).value = 0;
you changed the last element internally, so the SortedList has no way to know that something changed and will result in (LIVE) SortedList that is actually not sorted."
I think that's not the point: fully agreed that mutating elements under the feet of the list isn't a good idea (no way for the list the handle), the point is setting the mutated element throws. From the perspective of an observer (like a sorted list) of the original list, it's just a replaced element and the observer must cope with it
- relates to
-
JDK-8101447 Provide ObservableList implementation that copes with mutable elements
- Closed