|
@@ -40,8 +40,9 @@ static void setBits(int* data, int index, int bits, int value) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-BitArray::BitArray(int length, int bits)
|
|
|
|
|
|
+BitArray::BitArray(int length, int bits, int value)
|
|
: length(length), bits(bits), data(new int[roundUpDivide(length * bits, sizeof(int))]) {
|
|
: length(length), bits(bits), data(new int[roundUpDivide(length * bits, sizeof(int))]) {
|
|
|
|
+ fill(value);
|
|
}
|
|
}
|
|
|
|
|
|
BitArray::~BitArray() {
|
|
BitArray::~BitArray() {
|
|
@@ -100,6 +101,12 @@ int BitArray::getBits() const {
|
|
return bits;
|
|
return bits;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void BitArray::fill(int value) {
|
|
|
|
+ for(int i = 0; i < length; i++) {
|
|
|
|
+ set(i, value);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
void BitArray::resize(int newBits) {
|
|
void BitArray::resize(int newBits) {
|
|
int* newData = new int[roundUpDivide(length * newBits, sizeof(int))];
|
|
int* newData = new int[roundUpDivide(length * newBits, sizeof(int))];
|
|
for(int i = 0; i < length; i++) {
|
|
for(int i = 0; i < length; i++) {
|