RFR: 8349525: RBTree: provide leftmost, rightmost, and a simple way to print trees
Thomas Stuefe
stuefe at openjdk.org
Fri Feb 7 07:04:10 UTC 2025
On Thu, 6 Feb 2025 13:56:23 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:
>> For things I currently work on (compilation memory statistic), I need this functionality.
>>
>> Changes:
>>
>> - added leftmost() and rightmost() (pretty self-explanatory)
>> - added print_on(outputStream*) (likewise)
>> - const correctness
>> - other minor cleanups
>> - gtests for all added functions
>>
>> Tests: GHA (all clean), manual tests on Linux x64
>
> src/hotspot/share/utilities/rbTree.inline.hpp line 561:
>
>> 559: void print_T(outputStream* st, T x) {
>> 560: st->print(PTR_FORMAT, p2i(x));
>> 561: }
>
> I've done something like this before but ended up not integrating it. Seems like this is something we should have in a generic place, in the future. Just a note, nothing to fix.
I agree
> src/hotspot/share/utilities/rbTree.inline.hpp line 568:
>
>> 566: st->sp(1 + depth * 2);
>> 567: st->print("@" PTR_FORMAT ": [", p2i(n));
>> 568: print_T<K>(st, n->key());
>
> Do you need to provide the template parameter because key and val returns references? I would've assumed that C++ can infer the type and pick the right function.
More for expressiveness
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23486#discussion_r1946044334
PR Review Comment: https://git.openjdk.org/jdk/pull/23486#discussion_r1946044635
More information about the hotspot-dev
mailing list