Started the transission of char containers to unsinged char. By changing BitArray, there are 100 our of 1100 more tests that succeed.

This commit is contained in:
favoritas37 2016-05-24 21:27:45 +03:00
parent 995c01a5c8
commit afbe30fe0d
2 changed files with 10 additions and 10 deletions

View File

@ -90,12 +90,12 @@ bool BitArray::isRange(int start, int end, bool value) {
return true;
}
vector<int>& BitArray::getBitArray() {
vector<unsigned char>& BitArray::getBitArray() {
return bits->values();
}
void BitArray::reverse() {
ArrayRef<int> newBits(bits->size());
ArrayRef<unsigned char> newBits(bits->size());
int size = this->size;
for (int i = 0; i < size; i++) {
if (get(size - i - 1)) {
@ -197,7 +197,7 @@ void BitArray::ensureCapacity(int size)
{
if (size > bits->size() * 32)
{
ArrayRef<int> newBits = makeArray(size);
ArrayRef<unsigned char> newBits = makeArray(size);
//memcpy(bits, newBits->, bits->size());
for (size_t i=0; i<bits->size(); ++i) {
newBits[i] = bits[i];
@ -219,7 +219,7 @@ void BitArray::xor_(const BitArray& other)
}
}
void BitArray::toBytes(int bitOffset, std::vector<char>& array, int offset, int numBytes) const
void BitArray::toBytes(int bitOffset, std::vector<unsigned char>& array, int offset, int numBytes) const
{
if(array.size() < (numBytes + offset))
array.resize(numBytes + offset);
@ -232,6 +232,6 @@ void BitArray::toBytes(int bitOffset, std::vector<char>& array, int offset, int
}
bitOffset++;
}
array[offset + i] = (char) theByte;
array[offset + i] = (unsigned char) theByte;
}
}

View File

@ -35,7 +35,7 @@ public:
private:
int size;
ArrayRef<int> bits;
ArrayRef<unsigned char> bits;
static const int logBits = ZX_LOG_DIGITS(bitsPerWord);
static const int bitsMask = (1 << logBits) - 1;
@ -61,7 +61,7 @@ public:
void setRange(int start, int end);
void clear();
bool isRange(int start, int end, bool value);
std::vector<int>& getBitArray();
std::vector<unsigned char>& getBitArray();
void appendBit(bool bit);
void appendBits(int value, int numBits);
@ -70,10 +70,10 @@ public:
void xor_(const BitArray& other);
void toBytes(int bitOffset, std::vector<char>& array, int offset, int numBytes) const;
void toBytes(int bitOffset, std::vector<unsigned char>& array, int offset, int numBytes) const;
static ArrayRef<int> makeArray(int size) {
return ArrayRef<int>((size + 31) / 32);
static ArrayRef<unsigned char> makeArray(int size) {
return ArrayRef<unsigned char>((size + 31) / 32);
}
void reverse();