bitvec icon indicating copy to clipboard operation
bitvec copied to clipboard

Feature Request: `iter_ones_from`

Open Spoonbender opened this issue 3 years ago • 1 comments
trafficstars

Currently, iter_ones and iter_zeros always begin from the first position (front is set to zero) and there is no easy way to begin iterating at a certain position.

It would be helpful if we could call iter_ones_from(start_index) in order to start iterating the ones from the specified position (note: position in the bitvec, not within the ones). Same for iter_zeros_from of course.

This is somewhat achievable using slices, but requires book-keeping in order to recalculate the absolute indexes from the slice-relative indexes.

If this sounds like a good addition, I'd be glad to try and send a PR.

Spoonbender avatar Nov 20 '22 16:11 Spoonbender

What would be the difference between bits_full.iter_ones_from(start) and bits_full[start ..].iter_ones()?

myrrlyn avatar Nov 22 '22 04:11 myrrlyn