Browse Source

bit array internal size

Kajetan Johannes Hammerle 2 years ago
parent
commit
3659701342
2 changed files with 8 additions and 0 deletions
  1. 7 0
      data/BitArray.cpp
  2. 1 0
      data/BitArray.h

+ 7 - 0
data/BitArray.cpp

@@ -86,6 +86,13 @@ int BitArray::getBits() const {
     return bits;
 }
 
+int BitArray::getInternalByteSize() const {
+    if(bits <= 0 || length <= 0) {
+        return 0;
+    }
+    return roundUpDivide(length * bits, sizeof(int)) * sizeof(int);
+}
+
 void BitArray::fill(int value) {
     for(int i = 0; i < length; i++) {
         set(i, value);

+ 1 - 0
data/BitArray.h

@@ -21,6 +21,7 @@ public:
 
     int getLength() const;
     int getBits() const;
+    int getInternalByteSize() const;
 
     void resize(int newLength, int newBits);