[concurrency-interest] ConcurrentNavigableMap has two keySet

Joshua Bloch josh at bloch.us
Tue Jun 6 11:13:09 EDT 2006


Rémi,

Ah, would that it were.  ConcurrentNavigableMap extends NavigableMap.
NavigableMap needs both of these methods, as they have different return
types in NavigableMap.  We were unable to refine the return type of keySet
in NavigableMap for historical reasons: TreeMap was retrofitted to implement
NavigableMap.  TreeMap was non-final, so people have already extended it and
overridden keySet with a method that returns a Map rather than a
NavigableMap.  Had we refined the return type of NavigableMap.keySet(), we
would have broken those subclasses.  The reason that we were able to refine
the return type of ConcurrentNavigableMap is because there are no existing
implementations to break: there is no ConcurrentSortedMap, and
ConcurrentSkipListMap is brand new.

         Josh

P.S.  The reason that SortedMap did not refine the return type of keySet is
that covariant returns were not yet part of the language when I wrote it;
SortedMap has existed since 1.2 (1998), and covariant return types were
added in Tiger (2004).

On 6/6/06, Rémi Forax <forax at univ-mlv.fr> wrote:
>
> It seems that during the last changes (perhaps corresponding to bug
> 6415641)
> two different methods to obtain a NavigableSet
> in ConcurrentNavigableMap was introduced.
>
> |*keySet
> <
> http://download.java.net/jdk6/docs/api/java/util/concurrent/ConcurrentNavigableMap.html#keySet%28%29
> >*()|
>
>           Returns a |NavigableSet|
> <http://download.java.net/jdk6/docs/api/java/util/NavigableSet.html>
> view of the keys contained in this map.
> |*navigableKeySet
> <
> http://download.java.net/jdk6/docs/api/java/util/concurrent/ConcurrentNavigableMap.html#navigableKeySet%28%29
> >*()|
>
>           Returns a |NavigableSet|
> <http://download.java.net/jdk6/docs/api/java/util/NavigableSet.html>
> view of the keys contained in this map.
>
>
> see
>
> http://download.java.net/jdk6/docs/api/java/util/concurrent/ConcurrentNavigableMap.html
>
> I think that navigableKeySet() can be removed from
> ConcurrentNavigableMap and
> its implementation ConcurrentSkipListMap.
>
> Rémi Forax
>
>
>
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at altair.cs.oswego.edu
> http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20060606/7ddbfae5/attachment.html 


More information about the Concurrency-interest mailing list