|
tesseract 3.04.01
|
#include <bitvector.h>
Public Member Functions | |
| BitVector () | |
| BitVector (int length) | |
| BitVector (const BitVector &src) | |
| BitVector & | operator= (const BitVector &src) |
| ~BitVector () | |
| void | Init (int length) |
| int | size () const |
| bool | Serialize (FILE *fp) const |
| bool | DeSerialize (bool swap, FILE *fp) |
| void | SetAllFalse () |
| void | SetAllTrue () |
| void | SetBit (int index) |
| void | ResetBit (int index) |
| void | SetValue (int index, bool value) |
| bool | At (int index) const |
| bool | operator[] (int index) const |
| int | NextSetBit (int prev_bit) const |
| int | NumSetBits () const |
| void | operator|= (const BitVector &other) |
| void | operator&= (const BitVector &other) |
| void | operator^= (const BitVector &other) |
| void | SetSubtract (const BitVector &v1, const BitVector &v2) |
Static Public Attributes | |
| static const uinT8 | lsb_index_ [256] |
| static const uinT8 | lsb_eroded_ [256] |
| static const int | hamming_table_ [256] |
Definition at line 34 of file bitvector.h.
| tesseract::BitVector::BitVector | ( | ) |
Definition at line 110 of file bitvector.cpp.
| tesseract::BitVector::BitVector | ( | int | length | ) | [explicit] |
Definition at line 112 of file bitvector.cpp.
| tesseract::BitVector::BitVector | ( | const BitVector & | src | ) |
Definition at line 117 of file bitvector.cpp.
| tesseract::BitVector::~BitVector | ( | ) |
Definition at line 128 of file bitvector.cpp.
| bool tesseract::BitVector::At | ( | int | index | ) | const [inline] |
Definition at line 85 of file bitvector.h.
{
return (array_[WordIndex(index)] & BitMask(index)) != 0;
}
| bool tesseract::BitVector::DeSerialize | ( | bool | swap, |
| FILE * | fp | ||
| ) |
Definition at line 149 of file bitvector.cpp.
| void tesseract::BitVector::Init | ( | int | length | ) |
Definition at line 133 of file bitvector.cpp.
| int tesseract::BitVector::NextSetBit | ( | int | prev_bit | ) | const |
Definition at line 175 of file bitvector.cpp.
{
if (bit_index + 8 > next_bit && byte != 0) {
while (bit_index + lsb_index_[byte] < next_bit && byte != 0)
byte = lsb_eroded_[byte];
if (byte != 0)
return bit_index + lsb_index_[byte];
}
word >>= 8;
bit_index += 8;
byte = word & 0xff;
}
// next_word didn't contain a 1, so find the next word with set bit.
++next_word;
int wordlen = WordLength();
while (next_word < wordlen && (word = array_[next_word]) == 0) {
++next_word;
bit_index += kBitFactor;
}
if (bit_index >= bit_size_) return -1;
// Find the first non-zero byte within the word.
while ((word & 0xff) == 0) {
word >>= 8;
bit_index += 8;
}
return bit_index + lsb_index_[word & 0xff];
}
| int tesseract::BitVector::NumSetBits | ( | ) | const |
Definition at line 213 of file bitvector.cpp.
{
uinT32 word = array_[w];
for (int i = 0; i < 4; ++i) {
total_bits += hamming_table_[word & 0xff];
word >>= 8;
}
}
return total_bits;
}
| void tesseract::BitVector::operator&= | ( | const BitVector & | other | ) |
Definition at line 233 of file bitvector.cpp.
{
Definition at line 122 of file bitvector.cpp.
| bool tesseract::BitVector::operator[] | ( | int | index | ) | const [inline] |
Definition at line 88 of file bitvector.h.
{
return (array_[WordIndex(index)] & BitMask(index)) != 0;
}
| void tesseract::BitVector::operator^= | ( | const BitVector & | other | ) |
Definition at line 240 of file bitvector.cpp.
| void tesseract::BitVector::operator|= | ( | const BitVector & | other | ) |
Definition at line 228 of file bitvector.cpp.
{
| void tesseract::BitVector::ResetBit | ( | int | index | ) | [inline] |
Definition at line 76 of file bitvector.h.
{
array_[WordIndex(index)] &= ~BitMask(index);
}
| bool tesseract::BitVector::Serialize | ( | FILE * | fp | ) | const |
Definition at line 139 of file bitvector.cpp.
| void tesseract::BitVector::SetAllFalse | ( | ) |
Definition at line 166 of file bitvector.cpp.
{
| void tesseract::BitVector::SetAllTrue | ( | ) |
Definition at line 169 of file bitvector.cpp.
| void tesseract::BitVector::SetBit | ( | int | index | ) | [inline] |
Definition at line 73 of file bitvector.h.
{
array_[WordIndex(index)] |= BitMask(index);
}
Definition at line 246 of file bitvector.cpp.
| void tesseract::BitVector::SetValue | ( | int | index, |
| bool | value | ||
| ) | [inline] |
Definition at line 79 of file bitvector.h.
| int tesseract::BitVector::size | ( | ) | const [inline] |
Definition at line 57 of file bitvector.h.
{
return bit_size_;
}
const int tesseract::BitVector::hamming_table_ [static] |
{
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
}
Definition at line 44 of file bitvector.h.
const uinT8 tesseract::BitVector::lsb_eroded_ [static] |
Definition at line 42 of file bitvector.h.
usr src packages BUILD tesseract ccutil bitvector cpp const uinT8 tesseract::BitVector::lsb_index_ [static] |
{
255, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
}
Definition at line 39 of file bitvector.h.