[concurrency-interest] subList, subMap and navigable

Doug Lea dl at cs.oswego.edu
Mon Jul 23 14:18:51 EDT 2012


On 07/23/12 14:00, Stanimir Simeonoff wrote:

> TreeMap:: NavigableSubMap<K,V> extends AbstractMap<K,V>
>          implements NavigableMap<K,V>, java.io.Serializable {

> ConcurrentSkipListMap::    static final class SubMap<K,V> extends AbstractMap<K,V>
>          implements ConcurrentNavigableMap<K,V>, Cloneable,
>                     java.io.Serializable {

I'm not sure why this was done. My fuzzy recollection is that
TreeMap initially did do for some reason, and CSLM did the same
to maintain pluggability. But in general, you can't count on
serializability of views.

>
> Btw, any insight on the 2nd question about the introduction of Navigable?

The short answer is that Navigable exists because we didn't
have anything like upcoming "defenders" -- Sorted didn't
describe all the common functionality, and there was no way
to do so except to introduce a new interface. In practice,
I'm sure "Sorted" is still used much more often than "Navigable"
as a declaration type, because most people don't need the
methods defined in Navigable but not Sorted. Plus "Navigable"
is just not a very nice name :-)

-Doug


More information about the Concurrency-interest mailing list