Closed
Description
unordered-containers/Data/HashMap/Internal.hs
Lines 1615 to 1643 in 7237826
I don't quite understand this code yet, but the comment reminds me of this use of countTrailingZeros
to find the next 1
bit:
elems ::
( BitOffset a
, FiniteBits b
, IndexableBits b
, Eq b
) => BitSet b a -> [a]
elems (BitSet b) = go b
where
go !c
| c == zeroBits = []
| otherwise = let e = countTrailingZeros c in fromBitOffset e : go (clearBit c e)