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.
Having an iterator over the bits that are set to
1
(or0
) 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 theas_slice()
method, but this would make assumptions about the order in which bits are stored in theu32
. This can be efficiently implemented usingbsf
(bit-scan-forward x86) or equivalent operations.