RFR: 8343125: Correct the documentation for TreeMap's getFloorEntry and getCeilingEntry [v2]

Archie Cobbs acobbs at openjdk.org
Thu Nov 14 02:40:24 UTC 2024


On Thu, 14 Nov 2024 02:29:27 GMT, Naman Nigam <duke at openjdk.org> wrote:

>> As the documentation of getCeilingEntry currently reads, the inference is misleading as follows:
>> 
>> if no such entry exists, returns the entry for the least key greater than the specified key;
>> if no such entry exists (i.e., the greatest key in the Tree is less than the specified key), returns {@code null}
>> Have modified the first section to ensure that its clear that the value returned is upon existence of the key. Added a similar change for getFloorEntry.
>
> Naman Nigam has updated the pull request incrementally with one additional commit since the last revision:
> 
>   JDK-8343125 : Resolve a bad merge

src/java.base/share/classes/java/util/TreeMap.java line 424:

> 422:     /**
> 423:      * Returns the entry for the least key greater than or equal to the specified key;
> 424:      * if no such entry exists (i.e. the specified key is greater than any key in the tree),

I'd suggest changing "the specified key is greater than any key in the tree" → "the specified key is greater than any key in the tree, or the tree is empty"; same thing for `getFloorEntry()`.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/21729#discussion_r1841482450


More information about the core-libs-dev mailing list