|
@@ -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))]) {
|
|
|
+ fill(value);
|
|
|
}
|
|
|
|
|
|
BitArray::~BitArray() {
|
|
@@ -100,6 +101,12 @@ int BitArray::getBits() const {
|
|
|
return bits;
|
|
|
}
|
|
|
|
|
|
+void BitArray::fill(int value) {
|
|
|
+ for(int i = 0; i < length; i++) {
|
|
|
+ set(i, value);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void BitArray::resize(int newBits) {
|
|
|
int* newData = new int[roundUpDivide(length * newBits, sizeof(int))];
|
|
|
for(int i = 0; i < length; i++) {
|