BitArray.h 999 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef CORE_BIT_ARRAY_H
  2. #define CORE_BIT_ARRAY_H
  3. #include "utils/Check.h"
  4. #include "utils/String.h"
  5. namespace Core {
  6. class BitArray final {
  7. int length;
  8. int bits;
  9. int* data;
  10. public:
  11. BitArray();
  12. BitArray(const BitArray& other) = delete;
  13. BitArray(BitArray&& other);
  14. ~BitArray();
  15. BitArray& operator=(const BitArray& other) = delete;
  16. BitArray& operator=(BitArray&& other);
  17. // returns true on error
  18. check_return bool copyFrom(const BitArray& other);
  19. BitArray& set(int index, int value);
  20. int get(int index) const;
  21. int getLength() const;
  22. int getBits() const;
  23. int getInternalByteSize() const;
  24. int select(int index) const;
  25. // returns true on error
  26. check_return bool resize(int newLength, int newBits);
  27. void fill(int value);
  28. void toString(String& s) const;
  29. private:
  30. void swap(BitArray& other);
  31. };
  32. }
  33. #endif