Use a 64-bit bitmap rather than a 32-bit bitmap.

This commit is contained in:
Dr. Chat
2015-12-28 10:52:22 -06:00
committed by Ben Vanik
parent 764dcba75a
commit 6108ff1608
3 changed files with 25 additions and 24 deletions

View File

@@ -20,13 +20,13 @@ class BitMap {
public:
BitMap();
// Size is the number of entries, must be a multiple of 32.
// Size is the number of entries, must be a multiple of 64.
BitMap(size_t size_bits);
// Data does not have to be aligned to a 4-byte boundary, but it is
// preferable.
// Size is the number of entries, must be a multiple of 32.
BitMap(uint32_t* data, size_t size_bits);
// Size is the number of entries, must be a multiple of 64.
BitMap(uint64_t* data, size_t size_bits);
// (threadsafe) Acquires an entry and returns its index. Returns -1 if there
// are no more free entries.
@@ -35,19 +35,19 @@ class BitMap {
// (threadsafe) Releases an entry by an index.
void Release(size_t index);
// Resize the bitmap. Size is the number of entries, must be a multiple of 32.
// Resize the bitmap. Size is the number of entries, must be a multiple of 64.
void Resize(size_t new_size_bits);
// Sets all entries to free.
void Reset();
const std::vector<uint32_t> data() const { return data_; }
std::vector<uint32_t>& data() { return data_; }
const std::vector<uint64_t> data() const { return data_; }
std::vector<uint64_t>& data() { return data_; }
private:
const static uint32_t kDataSize = 4;
const static uint32_t kDataSizeBits = kDataSize * 8;
std::vector<uint32_t> data_;
const static size_t kDataSize = 8;
const static size_t kDataSizeBits = kDataSize * 8;
std::vector<uint64_t> data_;
};
} // namespace xe