23 #ifndef TESSERACT_CCUTIL_BITVECTOR_H__ 24 #define TESSERACT_CCUTIL_BITVECTOR_H__ 54 void Init(
int length);
74 array_[WordIndex(index)] |= BitMask(index);
77 array_[WordIndex(index)] &= ~BitMask(index);
85 bool At(
int index)
const {
86 return (array_[WordIndex(index)] & BitMask(index)) != 0;
89 return (array_[WordIndex(index)] & BitMask(index)) != 0;
109 void Alloc(
int length);
113 int WordIndex(
int index)
const {
114 assert(0 <= index && index < bit_size_);
115 return index / kBitFactor;
118 uinT32 BitMask(
int index)
const {
119 return 1 << (index & (kBitFactor - 1));
123 int WordLength()
const {
124 return (bit_size_ + kBitFactor - 1) / kBitFactor;
127 int ByteLength()
const {
128 return WordLength() *
sizeof(*array_);
138 static const int kBitFactor =
sizeof(
uinT32) * 8;
143 #endif // TESSERACT_CCUTIL_BITVECTOR_H__
void operator|=(const BitVector &other)
bool operator[](int index) const
void SetValue(int index, bool value)
void operator^=(const BitVector &other)
static const uinT8 lsb_index_[256]
bool Serialize(FILE *fp) const
bool DeSerialize(bool swap, FILE *fp)
static const uinT8 lsb_eroded_[256]
BitVector & operator=(const BitVector &src)
int NextSetBit(int prev_bit) const
void SetSubtract(const BitVector &v1, const BitVector &v2)
static const int hamming_table_[256]
void operator &=(const BitVector &other)