Make bitmap methods const if not modifying the bitmap

This commit is contained in:
apio 2022-12-05 12:50:30 +01:00
parent 3b77ba6b04
commit 004e13a5f3
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 6 additions and 6 deletions

View File

@ -11,25 +11,25 @@ class Bitmap
void* move(void* new_location, usize new_location_size_in_bytes);
void set(usize index, bool value);
bool get(usize index);
bool get(usize index) const;
// size() returns size in bits! If you want the size in bytes, call size_in_bytes().
usize size()
usize size() const
{
return m_size_in_bytes * 8;
}
usize size_in_bytes()
usize size_in_bytes() const
{
return m_size_in_bytes;
}
void* location()
void* location() const
{
return (void*)m_location;
}
bool initialized()
bool initialized() const
{
return m_location;
}

View File

@ -42,7 +42,7 @@ void Bitmap::set(usize index, bool value)
if (value) { m_location[byte_index] |= bit_mask; }
}
bool Bitmap::get(usize index)
bool Bitmap::get(usize index) const
{
expect(initialized(), "Bitmap was never initialized");
expect(index < size(), "Bitmap access out of range");