final
class
Mask extends (Int) ⇒ Boolean
Instance Constructors
-
new
Mask(bits: Array[Long], size: Int)
Value Members
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
-
-
final
def
++(that: Mask): Mask
-
-
-
def
->[B](y: B): (Mask, B)
-
final
def
==(arg0: Any): Boolean
-
def
andThen[A](g: (Boolean) ⇒ A): (Int) ⇒ A
-
-
final
def
asInstanceOf[T0]: T0
-
def
clone(): AnyRef
-
def
compose[A](g: (A) ⇒ Int): (A) ⇒ Boolean
-
-
-
def
ensuring(cond: Boolean, msg: ⇒ Any): Mask
-
-
-
-
-
def
finalize(): Unit
-
def
foreach[U](f: (Int) ⇒ U): Unit
-
def
formatted(fmtstr: String): String
-
final
def
getClass(): Class[_]
-
def
hashCode(): Int
-
-
final
def
isInstanceOf[T0]: Boolean
-
-
-
-
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
val
size: Int
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
def
toBitSet: BitSet
-
def
toSet: Set[Int]
-
def
toString(): String
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
-
-
def
→[B](y: B): (Mask, B)
Shadowed Implicit Value Members
-
def
+(other: String): String
Inherited by implicit conversion any2stringadd from
Mask to any2stringadd[Mask]
Inherited by implicit conversion StringFormat from
Mask to StringFormat[Mask]
Inherited by implicit conversion Ensuring from
Mask to Ensuring[Mask]
Inherited by implicit conversion ArrowAssoc from
Mask to ArrowAssoc[Mask]
A
Mask
provides a dense bitset implementation. This replaces uses ofBitSet
. The major difference is that we don't box theInt
s.An explanation of some of the arithmetic you'll see here:
We store the bits in array of words. Each word contains 64 bits and the words are in order. So, the word containing bit
n
isn >>> 6
- we simply drop the lower 6 bits (divide by 64). Ifn
is set, then the bitn & 0x3FL
(the last 6 bits - ie n % 64 if n was an unsigned int), in wordbits(n >>> 6)
will betrue
. We can check this by masking the word with1L << (n & 0x3FL)
and checking if the result is non-zero.Note that we use shift-without-carry (
> > >
) and intersection (&
) to divide and mod by 64 instead of using/
and%
because they do not behave correctly with negative numbers; they carry the sign through in the result, and we want the absolute value.An invariant of the underlying
bits
array is that the highest order word (ie.bits(bits.length - 1)
) is always non-zero (except ifbits
has 0 length). This sometimes means we must *trim* the array for some operations that could possibly zero out the highest order word (eg. intersection and subtraction.