#ifndef CORE_BIT_ARRAY_H #define CORE_BIT_ARRAY_H #include "utils/ArrayString.h" namespace Core { class BitArray final { int length; int bits; int* data; public: BitArray(); BitArray(const BitArray& other) = delete; BitArray(BitArray&& other); ~BitArray(); BitArray& operator=(const BitArray& other) = delete; BitArray& operator=(BitArray&& other); // returns true on error check_return bool copyFrom(const BitArray& other); BitArray& set(int index, int value); int get(int index) const; int getLength() const; int getBits() const; int getInternalByteSize() const; int select(int index) const; // returns true on error check_return bool resize(int newLength, int newBits); void fill(int value); // returns true on error template check_return bool toString(ArrayString& s) const { if(s.append("[")) { return true; } for(int i = 0; i < length - 1; i++) { if(s.append(get(i)) || s.append(", ")) { return true; } } if(length > 0 && s.append(get(length - 1))) { return true; } return s.append("]"); } private: void swap(BitArray& other); }; } #endif