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0x2e,
49 0x20, 0x30, 0x30, 0x32, 0x30, 0x34, 0x34, 0x36, 0x30, 0x38, 0x38, 0x3a, 0x38, 0x3c, 0x3c, 0x3e,
50 0, 0x40, 0x40, 0x42, 0x40, 0x44, 0x44, 0x46, 0x40, 0x48, 0x48, 0x4a, 0x48, 0x4c, 0x4c, 0x4e,
51 0x40, 0x50, 0x50, 0x52, 0x50, 0x54, 0x54, 0x56, 0x50, 0x58, 0x58, 0x5a, 0x58, 0x5c, 0x5c, 0x5e,
52 0x40, 0x60, 0x60, 0x62, 0x60, 0x64, 0x64, 0x66, 0x60, 0x68, 0x68, 0x6a, 0x68, 0x6c, 0x6c, 0x6e,
53 0x60, 0x70, 0x70, 0x72, 0x70, 0x74, 0x74, 0x76, 0x70, 0x78, 0x78, 0x7a, 0x78, 0x7c, 0x7c, 0x7e,
54 0, 0x80, 0x80, 0x82, 0x80, 0x84, 0x84, 0x86, 0x80, 0x88, 0x88, 0x8a, 0x88, 0x8c, 0x8c, 0x8e,
55 0x80, 0x90, 0x90, 0x92, 0x90, 0x94, 0x94, 0x96, 0x90, 0x98, 0x98, 0x9a, 0x98, 0x9c, 0x9c, 0x9e,
56 0x80, 0xa0, 0xa0, 0xa2, 0xa0, 0xa4, 0xa4, 0xa6, 0xa0, 0xa8, 0xa8, 0xaa, 0xa8, 0xac, 0xac, 0xae,
57 0xa0, 0xb0, 0xb0, 0xb2, 0xb0, 0xb4, 0xb4, 0xb6, 0xb0, 0xb8, 0xb8, 0xba, 0xb8, 0xbc, 0xbc, 0xbe,
58 0x80, 0xc0, 0xc0, 0xc2, 0xc0, 0xc4, 0xc4, 0xc6, 0xc0, 0xc8, 0xc8, 0xca, 0xc8, 0xcc, 0xcc, 0xce,
59 0xc0, 0xd0, 0xd0, 0xd2, 0xd0, 0xd4, 0xd4, 0xd6, 0xd0, 0xd8, 0xd8, 0xda, 0xd8, 0xdc, 0xdc, 0xde,
60 0xc0, 0xe0, 0xe0, 0xe2, 0xe0, 0xe4, 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ordLength();
111 for (
int i = 0;
i < wordlen; ++
i) {
119 memset(&array_[0], 0, ByteLength());
122 memset(&array_[0], ~0, ByteLength());
129 int next_bit = prev_bit + 1;
130 if (next_bit >= bit_size_) {
134 int next_word = WordIndex(next_bit);
135 int bit_index = next_word * kBitFactor;
136 int word_end = bit_index + kBitFactor;
137 uint32_t word = array_[next_word];
138 uint8_t
byte = word & 0xff;
139 while (bit_index < word_end) {
140 if (bit_index + 8 > next_bit &&
byte != 0) {
141 while (bit_index +
lsb_index_[
byte] < next_bit &&
byte != 0) {
154 int wordlen = WordLength();
155 while (next_word < wordlen && (word = array_[next_word]) == 0) {
157 bit_index += kBitFactor;
159 if (bit_index >= bit_size_) {
163 while ((word & 0xff) == 0) {
172 int wordlen = WordLength();
174 for (
int w = 0; w < wordlen; ++w) {
175 uint32_t word = array_[w];
176 for (
int i = 0;
i < 4; ++
i) {
187 int length = std::min(WordLength(), other.WordLength());
188 for (
int w = 0; w < length; ++w) {
189 array_[w] |= other.array_[w];
193 int length = std::min(WordLength(), other.WordLength());
194 for (
int w = 0; w < length; ++w) {
195 array_[w] &= other.array_[w];
197 for (
int w = WordLength() - 1; w >= length; --w) {
202 int length = std::min(WordLength(), other.WordLength());
203 for (
int w = 0; w < length; ++w) {
204 array_[w] ^= other.array_[w];
210 int length = std::min(v1.WordLength(), v2.WordLength());
211 for (
int w = 0; w < length; ++w) {
212 array_[w] = v1.array_[w] ^ (v1.array_[w] & v2.array_[w]);
214 for (
int w = WordLength() - 1; w >= length; --w) {
215 array_[w] = v1.array_[w];
221void BitVector::Alloc(
int length) {
222 int initial_wordlength = WordLength();
224 int new_wordlength = WordLength();
225 if (new_wordlength != initial_wordlength) {
226 array_.resize(new_wordlength);
void ReverseN(void *ptr, int num_bytes)
bool DeSerialize(bool swap, FILE *fp, std::vector< T > &data)
bool Serialize(FILE *fp, const std::vector< T > &data)
static const uint8_t lsb_index_[256]
void operator^=(const BitVector &other)
static const int hamming_table_[256]
BitVector & operator=(const BitVector &src)
void SetSubtract(const BitVector &v1, const BitVector &v2)
void operator&=(const BitVector &other)
bool DeSerialize(bool swap, FILE *fp)
int NextSetBit(int prev_bit) const
void operator|=(const BitVector &other)
bool Serialize(FILE *fp) const
static const uint8_t lsb_eroded_[256]