Minor formatting cleanup.

git-svn-id: https://zxing.googlecode.com/svn/trunk@1562 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
dswitkin@google.com 2010-08-25 19:03:32 +00:00
parent aca11201ed
commit 886b70e167
4 changed files with 16 additions and 9 deletions

View file

@ -2,8 +2,7 @@
* BitArray.cpp * BitArray.cpp
* zxing * zxing
* *
* Created by Christian Brunschen on 09/05/2008. * Copyright 2010 ZXing authors. All rights reserved.
* Copyright 2008 Google UK. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,6 +24,7 @@
using namespace std; using namespace std;
namespace zxing { namespace zxing {
static unsigned int logDigits(unsigned digits) { static unsigned int logDigits(unsigned digits) {
unsigned log = 0; unsigned log = 0;
unsigned val = 1; unsigned val = 1;
@ -34,9 +34,11 @@ static unsigned int logDigits(unsigned digits) {
} }
return log; return log;
} }
const unsigned int BitArray::bitsPerWord_ = numeric_limits<unsigned int>::digits; const unsigned int BitArray::bitsPerWord_ = numeric_limits<unsigned int>::digits;
const unsigned int BitArray::logBits_ = logDigits(bitsPerWord_); const unsigned int BitArray::logBits_ = logDigits(bitsPerWord_);
const unsigned int BitArray::bitsMask_ = (1 << logBits_) - 1; const unsigned int BitArray::bitsMask_ = (1 << logBits_) - 1;
size_t BitArray::wordsForBits(size_t bits) { size_t BitArray::wordsForBits(size_t bits) {
int arraySize = bits >> logBits_; int arraySize = bits >> logBits_;
if (bits - (arraySize << logBits_) != 0) { if (bits - (arraySize << logBits_) != 0) {
@ -48,26 +50,33 @@ size_t BitArray::wordsForBits(size_t bits) {
BitArray::BitArray(size_t size) : BitArray::BitArray(size_t size) :
size_(size), bits_(wordsForBits(size), (const unsigned int)0) { size_(size), bits_(wordsForBits(size), (const unsigned int)0) {
} }
BitArray::~BitArray() { BitArray::~BitArray() {
} }
size_t BitArray::getSize() { size_t BitArray::getSize() {
return size_; return size_;
} }
bool BitArray::get(size_t i) { bool BitArray::get(size_t i) {
return (bits_[i >> logBits_] & (1 << (i & bitsMask_))) != 0; return (bits_[i >> logBits_] & (1 << (i & bitsMask_))) != 0;
} }
void BitArray::set(size_t i) { void BitArray::set(size_t i) {
bits_[i >> logBits_] |= 1 << (i & bitsMask_); bits_[i >> logBits_] |= 1 << (i & bitsMask_);
} }
void BitArray::setBulk(size_t i, unsigned int newBits) { void BitArray::setBulk(size_t i, unsigned int newBits) {
bits_[i >> logBits_] = newBits; bits_[i >> logBits_] = newBits;
} }
void BitArray::clear() { void BitArray::clear() {
size_t max = bits_.size(); size_t max = bits_.size();
for (size_t i = 0; i < max; i++) { for (size_t i = 0; i < max; i++) {
bits_[i] = 0; bits_[i] = 0;
} }
} }
bool BitArray::isRange(size_t start, size_t end, bool value) { bool BitArray::isRange(size_t start, size_t end, bool value) {
if (end < start) { if (end < start) {
throw IllegalArgumentException("end must be after start"); throw IllegalArgumentException("end must be after start");
@ -103,9 +112,11 @@ bool BitArray::isRange(size_t start, size_t end, bool value) {
} }
return true; return true;
} }
vector<unsigned int>& BitArray::getBitArray() { vector<unsigned int>& BitArray::getBitArray() {
return bits_; return bits_;
} }
void BitArray::reverse() { void BitArray::reverse() {
std::vector<unsigned int> newBits(bits_.size(),(const unsigned int) 0); std::vector<unsigned int> newBits(bits_.size(),(const unsigned int) 0);
for (size_t i = 0; i < size_; i++) { for (size_t i = 0; i < size_; i++) {

View file

@ -2,8 +2,7 @@
* BitMatrix.cpp * BitMatrix.cpp
* zxing * zxing
* *
* Created by Christian Brunschen on 12/05/2008. * Copyright 2010 ZXing authors. All rights reserved.
* Copyright 2008 Google UK. All rights reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -38,7 +37,6 @@ unsigned int logDigits(unsigned digits) {
return log; return log;
} }
const unsigned int bitsPerWord = numeric_limits<unsigned int>::digits; const unsigned int bitsPerWord = numeric_limits<unsigned int>::digits;
const unsigned int logBits = logDigits(bitsPerWord); const unsigned int logBits = logDigits(bitsPerWord);
const unsigned int bitsMask = (1 << logBits) - 1; const unsigned int bitsMask = (1 << logBits) - 1;

View file

@ -2,9 +2,7 @@
* GlobalHistogramBinarizer.cpp * GlobalHistogramBinarizer.cpp
* zxing * zxing
* *
* Created by Ralf Kistner on 16/10/2009. * Copyright 2010 ZXing authors. All rights reserved.
* Copyright 2008 ZXing authors All rights reserved.
* Modified by Lukasz Warchol on 02/02/2010.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -40,7 +40,7 @@ namespace zxing {
*/ */
const int L_PATTERNS_LEN = 10; const int L_PATTERNS_LEN = 10;
const int L_PATTERNS_SUB_LEN = 4; const int L_PATTERNS_SUB_LEN = 4;
const int L_PATTERNS[10][4] = { const int L_PATTERNS[L_PATTERNS_LEN][L_PATTERNS_SUB_LEN] = {
{3, 2, 1, 1}, // 0 {3, 2, 1, 1}, // 0
{2, 2, 2, 1}, // 1 {2, 2, 2, 1}, // 1
{2, 1, 2, 2}, // 2 {2, 1, 2, 2}, // 2