Any way to do a binary tree traversal without `opApply` and allocations?

monkyyy crazymonkyyy at gmail.com
Fri Mar 27 10:15:50 UTC 2026


On Thursday, 26 March 2026 at 21:47:59 UTC, solidstate1991 wrote:
>
> Is there some other way to implement a tree traversal, that 
> preferably works with `foreach`

https://forum.dlang.org/thread/shqwthzzrrorowdqczzs@forum.dlang.org

I think theres better ways to do it then this gist but intrusive 
lists

Im unsure what problems you have with the anti-work keywords, but 
you have at least three options with what ive seen:

smart handles: mixin+index, limits you to 1 array but elements 
know where root is implictly

add indexes to your types: assume the root is index 0 or 1, then 
you should be able to generate a range from the array

add an index array to your datastructure.

inb4 this gets stuck in moderation queue forever


More information about the Digitalmars-d-learn mailing list