RFR: 8345314: Add a red–black tree as a utility data structure
Casper Norrbin
cnorrbin at openjdk.org
Mon Dec 2 15:46:15 UTC 2024
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 att 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.
-------------
Commit messages:
- removed whitespace
- reverted vmatree
- more feedback fixes
- Merge branch 'master' into rb-tree
- encoded color in black height
- removed split/merge/update_key
- find_enclosing_range and edit key
- test changes
- iterator
- min/max fix
- ... and 5 more: https://git.openjdk.org/jdk/compare/a032de29...1b45feaf
Changes: https://git.openjdk.org/jdk/pull/22360/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=22360&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8345314
Stats: 1157 lines in 2 files changed: 1157 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/22360.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/22360/head:pull/22360
PR: https://git.openjdk.org/jdk/pull/22360
More information about the hotspot-dev
mailing list