Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iter_ones() and iter_zeros() iterator. #7

Closed
mneumann opened this issue Dec 1, 2016 · 1 comment · Fixed by #89
Closed

Add iter_ones() and iter_zeros() iterator. #7

mneumann opened this issue Dec 1, 2016 · 1 comment · Fixed by #89

Comments

@mneumann
Copy link
Contributor

mneumann commented Dec 1, 2016

Having an iterator over the bits that are set to 1 (or 0) would be a nice addition. For example, it would speed up this loop of my Kuhn-Munkres implementation. I could implement it myself by using the as_slice() method, but this would make assumptions about the order in which bits are stored in the u32. This can be efficiently implemented using bsf (bit-scan-forward x86) or equivalent operations.

@bluss
Copy link
Member

bluss commented Dec 1, 2016

bit index when accessed like block & (1 << i) is arch independent, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants