BitArray.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef CORE_BIT_ARRAY_HPP
  2. #define CORE_BIT_ARRAY_HPP
  3. #include "core/utils/ArrayString.hpp"
  4. namespace Core {
  5. class BitArray final {
  6. u64 lengthBits;
  7. u64* data;
  8. public:
  9. BitArray();
  10. BitArray(const BitArray& other);
  11. BitArray(BitArray&& other);
  12. ~BitArray();
  13. BitArray& operator=(BitArray other);
  14. BitArray& set(size_t index, u64 value);
  15. u64 get(size_t index) const;
  16. size_t getLength() const;
  17. size_t getBits() const;
  18. size_t getInternalByteSize() const;
  19. i64 select(size_t index) const;
  20. CError resize(size_t newLength, size_t newBits);
  21. void fill(u64 value);
  22. void toString(BufferString& s) const {
  23. s.append("[");
  24. size_t length = getLength();
  25. if(length > 0) {
  26. length--;
  27. for(size_t i = 0; i < length; i++) {
  28. s.append(get(i)).append(", ");
  29. }
  30. s.append(get(length));
  31. }
  32. s.append("]");
  33. }
  34. void swap(BitArray& other);
  35. };
  36. }
  37. #endif