RFR: 8345314: Add a red–black tree as a utility data structure [v18]
Axel Boldt-Christmas
aboldtch at openjdk.org
Wed Jan 29 06:52:51 UTC 2025
On Tue, 28 Jan 2025 14:54:13 GMT, Casper Norrbin <cnorrbin at openjdk.org> wrote:
>> Hi everyone,
>>
>> This effort began as an exploration of replacing the current NMT treap with a red-black tree. Along the way, I discovered that others were also interested in having a general-purpose tree structure available within HotSpot.
>>
>> The red-black tree is designed to serve as a drop-in replacement for the existing NMT treap, keeping a nearly identical interface. However, I’ve also added a few additional requested features, such as an iterator.
>>
>> Testing builds off the treap tests, adding a few extra that inserts/removes and checks that the tree is correct. Testing uses the function `verify_self`, which iterates over the tree and checks that all red-black tree properties hold. Additionally, the tree has been tested in vmatree instead of the treap without any errors.
>>
>> For those who may want to revisit the fundamentals of red-black trees, [Wikipedia](https://en.wikipedia.org/wiki/Red%E2%80%93black_tree) offers a great summary with tables covering the various balancing cases. Alternatively, your favorite data structure book could provide even more insight.
>
> Casper Norrbin has updated the pull request incrementally with one additional commit since the last revision:
>
> |& and &= when setting colors
This looks really good now. Just a few more comments.
The parameter names should also be harmonised. At least for the public member functions. Right now both `k` and `key` is used, we should pick one (I like descriptive names in signatures, so I would pick the later, but I think the former use is more prevalent in your patch). And it should be consistent with `v`/`value`.
-------------
Changes requested by aboldtch (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/22360#pullrequestreview-2580086088
More information about the hotspot-dev
mailing list