#include <bitvector.h>
List of all members.
Detailed Description
Definition at line 34 of file bitvector.h.
Constructor & Destructor Documentation
tesseract::BitVector::BitVector |
( |
| ) |
|
tesseract::BitVector::BitVector |
( |
int |
length | ) |
|
|
explicit |
tesseract::BitVector::BitVector |
( |
const BitVector & |
src | ) |
|
Definition at line 35 of file bitvector.cpp.
: bit_size_(src.bit_size_) {
array_ =
new uinT32[WordLength()];
memcpy(array_, src.array_, ByteLength());
}
tesseract::BitVector::~BitVector |
( |
| ) |
|
Member Function Documentation
bool tesseract::BitVector::At |
( |
int |
index | ) |
const |
|
inline |
Definition at line 75 of file bitvector.h.
{
return (array_[WordIndex(index)] & BitMask(index)) != 0;
}
bool tesseract::BitVector::DeSerialize |
( |
bool |
swap, |
|
|
FILE * |
fp |
|
) |
| |
Definition at line 66 of file bitvector.cpp.
{
if (fread(&new_bit_size, sizeof(new_bit_size), 1, fp) != 1) return false;
if (swap) {
ReverseN(&new_bit_size,
sizeof(new_bit_size));
}
Alloc(new_bit_size);
int wordlen = WordLength();
if (fread(array_, sizeof(*array_), wordlen, fp) != wordlen) return false;
if (swap) {
for (int i = 0; i < wordlen; ++i)
ReverseN(&array_[i],
sizeof(array_[i]));
}
return true;
}
void tesseract::BitVector::Init |
( |
int |
length | ) |
|
Definition at line 40 of file bitvector.cpp.
{
Alloc(src.bit_size_);
memcpy(array_, src.array_, ByteLength());
return *this;
}
bool tesseract::BitVector::operator[] |
( |
int |
index | ) |
const |
|
inline |
Definition at line 78 of file bitvector.h.
{
return (array_[WordIndex(index)] & BitMask(index)) != 0;
}
void tesseract::BitVector::ResetBit |
( |
int |
index | ) |
|
|
inline |
Definition at line 66 of file bitvector.h.
{
array_[WordIndex(index)] &= ~BitMask(index);
}
bool tesseract::BitVector::Serialize |
( |
FILE * |
fp | ) |
const |
Definition at line 57 of file bitvector.cpp.
{
if (fwrite(&bit_size_, sizeof(bit_size_), 1, fp) != 1) return false;
int wordlen = WordLength();
if (fwrite(array_, sizeof(*array_), wordlen, fp) != wordlen) return false;
return true;
}
void tesseract::BitVector::SetAllFalse |
( |
| ) |
|
Definition at line 82 of file bitvector.cpp.
{
memset(array_, 0, ByteLength());
}
void tesseract::BitVector::SetAllTrue |
( |
| ) |
|
Definition at line 85 of file bitvector.cpp.
{
memset(array_, ~0, ByteLength());
}
void tesseract::BitVector::SetBit |
( |
int |
index | ) |
|
|
inline |
Definition at line 63 of file bitvector.h.
{
array_[WordIndex(index)] |= BitMask(index);
}
void tesseract::BitVector::SetValue |
( |
int |
index, |
|
|
bool |
value |
|
) |
| |
|
inline |
int tesseract::BitVector::size |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following files: