About SortedSet interface, java tutorial

java, list, sortedset

Solution

Let's say you have a list and a set both containing the integers `11`, `13`, `15` and `17`.

You could write `set.subSet(12, 15)` to construct a view, and then insert `12` into the original set. If you do this, `12` will appear in the view.

This is not possible with the list. Even though you can construct a view, the moment you modify the original list structurally (e.g. insert an element), the view becomes invalid.

Problem

Reading this Oracle tutorial I came across this explanation of the difference between the range-view operations of a List and the ones provided by the SortedSet interface. Here is the bit interested: The range-view operations are somewhat analogous to those provided by the List interface, but there is one big difference. Range views of a sorted set remain valid even if the backing sorted set is modified directly. This is feasible because the endpoints of a range view of a sorted set are absolute points in the element space rather than specific elements in the backing collection, as is the case for lists. Is anybody capable to explain the bold part with, let's say, other words? Thanks in advance.

Original source