示例#1
0
// Set subtraction *this = v1 - v2.
void BitVector::SetSubtract(const BitVector& v1, const BitVector& v2) {
  Alloc(v1.size());
  int length = MIN(v1.WordLength(), v2.WordLength());
  for (int w = 0; w < length; ++w)
    array_[w] = v1.array_[w] ^ (v1.array_[w] & v2.array_[w]);
  for (int w = WordLength() - 1; w >= length; --w)
    array_[w] = v1.array_[w];
}
示例#2
0
void BitVector::operator&=(const BitVector& other) {
  int length = MIN(WordLength(), other.WordLength());
  for (int w = 0; w < length; ++w)
    array_[w] &= other.array_[w];
  for (int w = WordLength() - 1; w >= length; --w)
    array_[w] = 0;
}
示例#3
0
void BitVector::operator^=(const BitVector& other) {
  int length = MIN(WordLength(), other.WordLength());
  for (int w = 0; w < length; ++w)
    array_[w] ^= other.array_[w];
}