23 #ifndef TESSERACT_CCUTIL_BITVECTOR_H__
24 #define TESSERACT_CCUTIL_BITVECTOR_H__
44 void Init(
int length);
64 array_[WordIndex(index)] |= BitMask(index);
67 array_[WordIndex(index)] &= ~BitMask(index);
75 bool At(
int index)
const {
76 return (array_[WordIndex(index)] & BitMask(index)) != 0;
79 return (array_[WordIndex(index)] & BitMask(index)) != 0;
84 void Alloc(
int length);
88 int WordIndex(
int index)
const {
89 assert(0 <= index && index < bit_size_);
90 return index / kBitFactor;
93 uinT32 BitMask(
int index)
const {
94 return 1 << (index & (kBitFactor - 1));
98 int WordLength()
const {
99 return (bit_size_ + kBitFactor - 1) / kBitFactor;
102 int ByteLength()
const {
103 return WordLength() *
sizeof(*array_);
111 static const int kBitFactor =
sizeof(
uinT32) * 8;
116 #endif // TESSERACT_CCUTIL_BITVECTOR_H__