RFR: 8345314: Add a red–black tree as a utility data structure [v17]

Casper Norrbin cnorrbin at openjdk.org
Wed Jan 29 10:13:56 UTC 2025


On Wed, 29 Jan 2025 06:19:36 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:

>> Casper Norrbin has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 36 commits:
>> 
>>  - merge fixes
>>  - Merge branch 'master' into rb-tree
>>  - readd find_enclosing_range
>>  - Merge branch 'master' into rb-tree
>>  - treap swap fix
>>  - const functions
>>  - thomas feedback
>>  - axel feedback
>>  - clarified comment
>>  - Improved comments
>>  - ... and 26 more: https://git.openjdk.org/jdk/compare/ad01dfb6...b7219a93
>
> src/hotspot/share/utilities/rbTree.hpp line 204:
> 
>> 202:   // Finds the node with the closest key <= the given key
>> 203:   // Change mode to EXCLUSIVE to not include node matching key
>> 204:   RBNode* closest_leq(const K& key, BoundMode mode = INCLUSIVE) {
> 
> Having a parameter value change the behaviour to contradict the name of the function feels a little evil. Might cause confusion and bugs in the future. I would rather have one `closest(Key, Direction, BoundMode)` and/or four `closest_[ls,leq,geq,gt](Key)`.

I kept it simple and separated them into separate functions. These are re-done more nicely with cursors in the intrusive version.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22360#discussion_r1933599964


More information about the hotspot-dev mailing list