Open etiwal opened 4 years ago
The fixed-depth iterators lack proper STL behaviour in the sense that there is no end-iterator. But you can still iterate over elements at a fixed depth by getting the begin-iterator using auto it = begin_fixed(...)
and then iterating until it.is_valid()
no longer returns true
. So something like
auto it = tr.begin_fixed(tr.begin(), 3);
while(it.is_valid()) {
tr.append_child(it, ...);
++it;
}
Hope this helps; if not, ask again.
auto it = tr.begin_fixed(tr.begin(), 3); while(it.is_valid()) { tr.append_child(it, ...); ++it; }
Sorry to revive an old question, but (unless I'm missing something) it looks like a fixed_depth_iterator doesn't have a is_valid()
method; should this be using something like:
auto it = tr.begin_fixed(tr.begin(), 3);
while (tr.is_valid(it)) {
tr.append_child(it, ...);
++it;
}
@jmccabe Yes, sorry.
When i try to use the fixed_depth iteration i am running into issues.
First of all this assertion always blocks my code from running: assert(1==0); // FIXME: not correct yet: use is_valid() as a temporary workaround
Also i have issues when using the begin_fixed() and end_fixed() to define the range of my iteration.
could you maybe provide an example on how to properly iterate over all the nodes at a certain depth and within this iteration create a child for every node?
Any help is greatly appreciated!