Batched collections iteration?

#1

I’ve recently read this short blog post:

It looks a bit like the opposite of this paper:

http://lafstern.org/matt/segmented.pdf

So is it worth adding a segmented API to the iteration of Rust stdlib HashSet, HashMap, BTreeSet, BTreeMap?

0 Likes

#2

Rust’s design helps a bunch here in that internal iteration can already choose to use nested loops if that’s better for the structure in question. For example, https://doc.rust-lang.org/1.25.0/src/alloc/vec_deque.rs.html#1958-1964

I think I’d always rather refactor a for loop to .for_each() over refactoring to nested-for-using-batched. (Or try_for_each, in 1.27, if I need early-exit.)

Also, I think Rust’s HashMap doesn’t use buckets, so doesn’t actually need batched/segmented iteration…

0 Likes

closed #3

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

0 Likes