I have a refactoring idea. It is not total rewrite, but will look better.
My main high level comment is that it feels like it may be easier not to put everything into a single position array. It's ok, but I wonder if it could become simpler.
Separate arrays…
I've refactored expand_selected_offsets
. It would be much simpler with proposed iterator, but for now it will do.
I doubted about this terminology myself, but it seemed nice in a context where positions from different domains are joined into one flat array. I'll think how to remove it.
My main high level comment is that it feels like it may be easier not to put everything into a single position array. It's ok, but I wonder if it could become simpler.
My first impression …
I decided to leave Aligned
and some other handle type dynamics for another patch.