Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
tesseract::BitVector Class Reference

`#include <bitvector.h>`

List of all members.

## 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

## Detailed Description

Definition at line 34 of file bitvector.h.

## Constructor & Destructor Documentation

tesseract::BitVector::BitVector | ( |  | ) |

Definition at line 28 of file bitvector.cpp.

: bit_size_(0), array_(NULL) {}

tesseract::BitVector::BitVector | ( | int | length | ) |

explicit

Definition at line 30 of file bitvector.cpp.

: bit_size_(length) {
array_ = new uinT32[WordLength()];
SetAllFalse();
}

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 | ( |  | ) |

Definition at line 46 of file bitvector.cpp.

{
delete [] array_;
}

## 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.

{
uinT32 new_bit_size;
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 51 of file bitvector.cpp.

{
Alloc(length);
SetAllFalse();
}

BitVector & tesseract::BitVector::operator= | ( | const BitVector & | src | ) |

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

Definition at line 69 of file bitvector.h.

{
if (value)
SetBit(index);
else
ResetBit(index);
}

int tesseract::BitVector::size | ( |  | ) | const

inline

Definition at line 47 of file bitvector.h.

{
return bit_size_;
}

The documentation for this class was generated from the following files:

- /mnt/data/src/tesseract-ocr/ccutil/bitvector.h
- /mnt/data/src/tesseract-ocr/ccutil/bitvector.cpp