On Friday, 20 September 2013 at 14:49:21 UTC, H. S. Teoh wrote:

snip
[...]

Some trees do, like document trees. But yeah, in general, you don't have
a natural ordering to trees.

But then again, the whole point of ranges is *linear* traversal. If you're not doing that, then it's probably the wrong abstraction to use. (FWIW, while SortedRange is a neat hack, I haven't actually found it that useful in practice. Most of the ranges I actually use are for the cases where it's an input/forward range and you don't want to store the whole thing, so random access is impractical. The cases where I actually have random access usually turn out to be plain ole arrays anyway, so
the SortedRange abstraction isn't really necessary.)

So for trees, I'd argue that you need a tree-specific iteration
abstraction, not ranges, which are linear. It's a clear case of
structure conflict. ;-)


T

Excuse my lack of knowledge on Ranges, so maybe what I am proposing is infeasible, for a binary tree for example couldn't you have a InOrderRange, PreOrderRange, and PostOrderRange or alternately DepthFirstRange, and BreadFirstRange. From a consumers view those would be linear operations?

Craig

Reply via email to