mirror of
https://github.com/zxing/zxing.git
synced 2025-01-13 04:07:27 -08:00
readd a couple of members not in tests
git-svn-id: https://zxing.googlecode.com/svn/trunk@2607 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
913f87b1ce
commit
b323e601b7
|
@ -120,62 +120,61 @@ void BitArray::reverse() {
|
|||
bits = newBits;
|
||||
}
|
||||
|
||||
/*
|
||||
BitArray::Reverse::Reverse(Ref<BitArray> array_) : array(array_) {
|
||||
BitArray::Reverse::Reverse(Ref<BitArray> array_) : array(array_) {
|
||||
array->reverse();
|
||||
}
|
||||
}
|
||||
|
||||
BitArray::Reverse::~Reverse() {
|
||||
BitArray::Reverse::~Reverse() {
|
||||
array->reverse();
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
namespace {
|
||||
// N.B.: This only works for 32 bit ints ...
|
||||
int numberOfTrailingZeros(int i) {
|
||||
// HD, Figure 5-14
|
||||
int y;
|
||||
if (i == 0) return 32;
|
||||
int n = 31;
|
||||
y = i <<16; if (y != 0) { n = n -16; i = y; }
|
||||
y = i << 8; if (y != 0) { n = n - 8; i = y; }
|
||||
y = i << 4; if (y != 0) { n = n - 4; i = y; }
|
||||
y = i << 2; if (y != 0) { n = n - 2; i = y; }
|
||||
return n - (((unsigned int)(i << 1)) >> 31);
|
||||
}
|
||||
// HD, Figure 5-14
|
||||
int y;
|
||||
if (i == 0) return 32;
|
||||
int n = 31;
|
||||
y = i <<16; if (y != 0) { n = n -16; i = y; }
|
||||
y = i << 8; if (y != 0) { n = n - 8; i = y; }
|
||||
y = i << 4; if (y != 0) { n = n - 4; i = y; }
|
||||
y = i << 2; if (y != 0) { n = n - 2; i = y; }
|
||||
return n - (((unsigned int)(i << 1)) >> 31);
|
||||
}
|
||||
}
|
||||
|
||||
int BitArray::getNextSet(int from) {
|
||||
if (from >= size_) {
|
||||
return size_;
|
||||
int BitArray::getNextSet(int from) {
|
||||
if (from >= size) {
|
||||
return size;
|
||||
}
|
||||
int bitsOffset = from >> 5;
|
||||
int currentBits = bits_[bitsOffset];
|
||||
int bitsOffset = from >> logBits;
|
||||
int currentBits = bits[bitsOffset];
|
||||
// mask off lesser bits first
|
||||
currentBits &= ~((1 << (from & 0x1F)) - 1);
|
||||
currentBits &= ~((1 << (from & bitsMask)) - 1);
|
||||
while (currentBits == 0) {
|
||||
if (++bitsOffset == (int)bits_.size()) {
|
||||
return size_;
|
||||
}
|
||||
currentBits = bits_[bitsOffset];
|
||||
}
|
||||
int result = (bitsOffset << 5) + numberOfTrailingZeros(currentBits);
|
||||
return result > size_ ? size_ : result;
|
||||
if (++bitsOffset == (int)bits.size()) {
|
||||
return size;
|
||||
}
|
||||
currentBits = bits[bitsOffset];
|
||||
}
|
||||
int result = (bitsOffset << logBits) + numberOfTrailingZeros(currentBits);
|
||||
return result > size ? size : result;
|
||||
}
|
||||
|
||||
int BitArray::getNextUnset(int from) {
|
||||
if (from >= size_) {
|
||||
return size_;
|
||||
int BitArray::getNextUnset(int from) {
|
||||
if (from >= size) {
|
||||
return size;
|
||||
}
|
||||
int bitsOffset = from >> 5;
|
||||
int currentBits = ~bits_[bitsOffset];
|
||||
int bitsOffset = from >> logBits;
|
||||
int currentBits = ~bits[bitsOffset];
|
||||
// mask off lesser bits first
|
||||
currentBits &= ~((1 << (from & 0x1F)) - 1);
|
||||
currentBits &= ~((1 << (from & bitsMask)) - 1);
|
||||
while (currentBits == 0) {
|
||||
if (++bitsOffset == (int)bits_.size()) {
|
||||
return size_;
|
||||
if (++bitsOffset == (int)bits.size()) {
|
||||
return size;
|
||||
}
|
||||
currentBits = ~bits[bitsOffset];
|
||||
}
|
||||
currentBits = ~bits_[bitsOffset];
|
||||
}
|
||||
int result = (bitsOffset << 5) + numberOfTrailingZeros(currentBits);
|
||||
return result > size_ ? size_ : result;
|
||||
}
|
||||
*/
|
||||
int result = (bitsOffset << logBits) + numberOfTrailingZeros(currentBits);
|
||||
return result > size ? size : result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue