fixedbitset
fixedbitset copied to clipboard
Add iter_ones() and iter_zeros() iterator.
trafficstars
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.
bit index when accessed like block & (1 << i) is arch independent, though.