Saturday, 28 September 2013

Scala mutable.BitSet intersection performance

Scala mutable.BitSet intersection performance

I am trying to write a backtracking algorithm that keeps state using
mutable BitSets, it works fine but I want it to go faster!
The crux is given two mutable.BitSet alpha and beta I need to calculate if
any of the bits of alpha are set in beta, i.e. bitwise AND. I do not need
the resulting set just need to know if the intersection isNonEmpty
(alpha intersect beta).nonEmpty
or
(alpha & beta).nonEmpty
but both of these construct a set which is then tested for size... I
really just need a boolean and would like to avoid the cost of
constructing the intermediate set.
Is there a better way?
TIA Nivag

No comments:

Post a Comment