ewrite the last section of the overwiew fo SortedMap documentation and a link fo NavigableMap

Chen Liang chen.l.liang at oracle.com
Sat Nov 2 17:13:23 UTC 2024


In addition, I discovered that a few methods, subMap, headMap, tailMap, sequencedKeySet, keySet, can be provided default implementations with covariant overrides.  This will bring convenience to both user implementations and API users, and adding covariant override is binary (but not source) compatible; example being LinkedList.

Another aspect is that the SequencedMap should explicitly override keySet, values, entrySet methods, asking users to implement the sequenced versions and delegate plain versions to return the sequenced versions instead.  This also troubles NavigableMap, but should be easy to fix (and is doc-only)

-Chen
________________________________
From: core-libs-dev <core-libs-dev-retn at openjdk.org> on behalf of Chen Liang <chen.l.liang at oracle.com>
Sent: Saturday, November 2, 2024 12:08 PM
To: Remi Forax <forax at univ-mlv.fr>; core-libs-dev <core-libs-dev at openjdk.java.net>
Cc: Stuart Marks <smarks at openjdk.java.net>
Subject: Re: ewrite the last section of the overwiew fo SortedMap documentation and a link fo NavigableMap

I strongly agree.  The use of SortedMap should be no longer preferred, like that for java.util.Stack/Vector.  We should update the Javadoc to refer to NavigableMap as the main total-ordered version and refer to SortedMap as a legacy interface.  In fact, we should probably override all SortedMap methods in NavigableMap, so IDE navigations never direct users to SortedMap.

Regards,
Chen Liang
________________________________
From: core-libs-dev <core-libs-dev-retn at openjdk.org> on behalf of Remi Forax <forax at univ-mlv.fr>
Sent: Saturday, November 2, 2024 8:13 AM
To: core-libs-dev <core-libs-dev at openjdk.java.net>
Cc: Stuart Marks <smarks at openjdk.java.net>
Subject: ewrite the last section of the overwiew fo SortedMap documentation and a link fo NavigableMap

Hello,
I was discussing with a student, she was trying to use the SortedMap interface but had trouble with tailMap() no being a strictly higher view from a key.
The solution was to use NavigableMap instead of SortedMap because it provides more methods to get lower/higher subMap and entries from keys.

I think we can improve de documentation of SortedMap (the last section (Note:) of the overview) by rewriting it saying that NavigableMap provides a richer API
instead of the current documentation that propose to add 1 or '\0' to the subMap() which is a ugly hack.

regards,
Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20241102/1c83d59b/attachment.htm>


More information about the core-libs-dev mailing list