Ralith / sieve-tree

6 stars 1 forks source link

Entire tree traversal #7

Closed grovesNL closed 1 day ago

grovesNL commented 4 days ago

This probably shouldn't be used often, but in some cases (even just external tests) it would be useful to have something like a entire tree iterator to iterate over all (id, bounds) pairs.

Ralith commented 3 days ago

The tree doesn't actually know the bounds of an element, just an upper bound. Would you want that?

grovesNL commented 3 days ago

The bounds would be useful to be able to queue (after traversal) some elements for removal based on their values, so I guess the upper bound would work for that, right?

Ralith commented 3 days ago

Ah, that makes sense, yeah.

Ralith commented 3 days ago

Counterpoint: why not fetch the bound from the T, as you're generally presumed to be able to do efficiently?

grovesNL commented 3 days ago

Yeah that sounds good, so the iterator could either return usize (look up the &T with get) or (usize, &T) pairs

Ralith commented 3 days ago

Probably (usize, &T), so that the iter_mut variant can yield a &mut T while the iterator is live.

Ralith commented 1 day ago

Implemented naively in 3d1bc7a31a737abec88eb30eb625de92fbc59153.