fixedbitset icon indicating copy to clipboard operation
fixedbitset copied to clipboard

Add iter_ones() and iter_zeros() iterator.

Open mneumann opened this issue 8 years ago • 1 comments
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.

mneumann avatar Dec 01 '16 08:12 mneumann

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

bluss avatar Dec 01 '16 16:12 bluss