BitArray.cppm 856 B

123456789101112131415161718192021222324252627282930313233
  1. module;
  2. export module Core.BitArray;
  3. import Core.Types;
  4. export namespace Core {
  5. class BitArray final {
  6. u64 length : 56;
  7. u64 bits : 8;
  8. u64* data;
  9. public:
  10. BitArray();
  11. BitArray(const BitArray& other);
  12. BitArray(BitArray&& other) noexcept;
  13. ~BitArray();
  14. BitArray& operator=(BitArray other) noexcept;
  15. BitArray& set(size_t index, u64 value);
  16. u64 get(size_t index) const;
  17. size_t getLength() const;
  18. size_t getBits() const;
  19. size_t getInternalByteSize() const;
  20. i64 select(size_t index) const;
  21. void resize(size_t newLength, size_t newBits);
  22. void fill(u64 value);
  23. size_t toString(char* s, size_t n) const;
  24. void swap(BitArray& other);
  25. };
  26. static_assert(sizeof(BitArray) == 16, "invalid bit array size");
  27. }