Implementing BitVector - 1
size_t BitVector::ByteNumber (size_t index) const
{
// return index / 8
// shift right 3 is equivalent to, and faster than, dividing by 8
index = index >> 3;
return index;
}
unsigned char BitVector::Mask (size_t index) const
{
// return mask for index % 8
// the low order 3 bits is the remainder when dividing by 8
size_t shiftamount = index & (size_t)0x07; // low order 3 bits
return 0x01 << shiftamount;
}