The operations can be efficiently implemented by shifting the 64 bit words of the backing array of the BitSet.
The implementation (in the form of extension methods) is readily available in scala-collection-contrib project:
<< can be emulated with .map(_ + shiftBy),
>> can be emulated with .collect { case b if b >= shiftBy => b - shiftBy },
but performance difference is up to two orders of magnitude.
Proposal
<<
and>>
) operations toBitSet
collection (both mutable and immutable)<<=
and>>=
) operations to mutableBitSet
Motivation
std::bitset
: https://en.cppreference.com/w/cpp/utility/bitset/operator_ltltgtgtImplementation
The operations can be efficiently implemented by shifting the 64 bit words of the backing array of the
BitSet
. The implementation (in the form of extension methods) is readily available inscala-collection-contrib
project:Alternatives
<<
can be emulated with.map(_ + shiftBy)
,>>
can be emulated with.collect { case b if b >= shiftBy => b - shiftBy }
, but performance difference is up to two orders of magnitude.