|
Tesseract
3.02
|
#include <qrsequence.h>
Public Member Functions | |
| QRSequenceGenerator (int N) | |
| int | GetVal () |
Protected Member Functions | |
| int | GetBinaryReversedInteger (int in_val) const |
Protected Attributes | |
| int | N_ |
| int | next_num_ |
| int | num_bits_ |
Definition at line 32 of file qrsequence.h.
| QRSequenceGenerator::QRSequenceGenerator | ( | int | N | ) | [inline, explicit] |
Definition at line 35 of file qrsequence.h.
| int QRSequenceGenerator::GetBinaryReversedInteger | ( | int | in_val | ) | const [inline, protected] |
Definition at line 58 of file qrsequence.h.
{
int bit_pos = num_bits_;
int out_val = 0;
while(bit_pos--) {
// Set the value of the last bit.
out_val |= (in_val & 0x1);
if (bit_pos > 0) {
// Left-shift output value to prepare for storing the next bit.
out_val <<= 1;
}
// Right-shift input value to prepare for retrieving the next bit.
in_val >>= 1;
}
return out_val;
}
| int QRSequenceGenerator::GetVal | ( | ) | [inline] |
Definition at line 41 of file qrsequence.h.
{
const int kInvalidVal = -1;
const int kMaxNaturalNumberValue = 1 << num_bits_;
if (next_num_ >= kMaxNaturalNumberValue)
return kInvalidVal;
int n = next_num_;
while (next_num_ < kMaxNaturalNumberValue) {
n = GetBinaryReversedInteger(next_num_++);
if (n < N_) break;
}
return (next_num_ > kMaxNaturalNumberValue) ? kInvalidVal : n;
}
int QRSequenceGenerator::N_ [protected] |
Definition at line 73 of file qrsequence.h.
int QRSequenceGenerator::next_num_ [protected] |
Definition at line 75 of file qrsequence.h.
int QRSequenceGenerator::num_bits_ [protected] |
Definition at line 77 of file qrsequence.h.