#ifndef CORE_BIT_ARRAY_HPP #define CORE_BIT_ARRAY_HPP #include "core/utils/ArrayString.hpp" 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); check_return Error 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; check_return Error resize(int newLength, int newBits); void fill(int value); template check_return Error toString(String& s) const { CORE_RETURN_ERROR(s.append("[")); for(int i = 0; i < length - 1; i++) { CORE_RETURN_ERROR(s.append(get(i))); CORE_RETURN_ERROR(s.append(", ")); } if(length > 0) { CORE_RETURN_ERROR(s.append(get(length - 1))); } return s.append("]"); } void swap(BitArray& other); }; } #endif