BitArray.cppm 847 B

12345678910111213141516171819202122232425262728293031
  1. export module Core.BitArray;
  2. import Core.Types;
  3. export namespace Core {
  4. class BitArray final {
  5. u64 length : 56;
  6. u64 bits : 8;
  7. u64* data;
  8. public:
  9. BitArray();
  10. BitArray(const BitArray& other);
  11. BitArray(BitArray&& other) noexcept;
  12. ~BitArray();
  13. BitArray& operator=(BitArray other) noexcept;
  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. void resize(size_t newLength, size_t newBits);
  21. void fill(u64 value);
  22. size_t toString(char* s, size_t n) const;
  23. void swap(BitArray& other);
  24. };
  25. static_assert(sizeof(BitArray) == 16, "invalid bit array size");
  26. }