rbtree to array?
Pete Padil
padil at gm.com
Tue May 6 16:49:32 UTC 2025
On Tuesday, 6 May 2025 at 06:50:36 UTC, Ferhat Kurtulmuş wrote:
> Rbtree has a range interface of d. Its memory layout is similar
> to a linked list, where the data is not contiguous. So, you
> have to copy the elements manually. But it is always a nice
> practice to use library functions, doing it for you.
>
> ```d
> import std.container.rbtree;
> import std.array;
>
> auto rbt = redBlackTree(3, 1, 4, 2, 5);
> auto arr = rbt[].array;
>
> writeln(arr);
> ```
Excellent - thank you!
More information about the Digitalmars-d-learn
mailing list