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

Kapendev alexandroskapretsos at gmail.com
Thu Mar 26 22:48:22 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` or at least somewhat easy to 
> use?

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 implicitly

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.


More information about the Digitalmars-d-learn mailing list