mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-06 04:49:19 +00:00
Update files
This commit is contained in:
28
Library/Bitmap.cpp
Normal file
28
Library/Bitmap.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include <bitmap.hpp>
|
||||
|
||||
bool Bitmap::operator[](uint64_t index) { return Get(index); }
|
||||
|
||||
bool Bitmap::Get(uint64_t index)
|
||||
{
|
||||
if (index > Size * 8)
|
||||
return false;
|
||||
uint64_t byteIndex = index / 8;
|
||||
uint8_t bitIndex = index % 8;
|
||||
uint8_t bitIndexer = 0b10000000 >> bitIndex;
|
||||
if ((Buffer[byteIndex] & bitIndexer) > 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Bitmap::Set(uint64_t index, bool value)
|
||||
{
|
||||
if (index > Size * 8)
|
||||
return false;
|
||||
uint64_t byteIndex = index / 8;
|
||||
uint8_t bitIndex = index % 8;
|
||||
uint8_t bitIndexer = 0b10000000 >> bitIndex;
|
||||
Buffer[byteIndex] &= ~bitIndexer;
|
||||
if (value)
|
||||
Buffer[byteIndex] |= bitIndexer;
|
||||
return true;
|
||||
}
|
Reference in New Issue
Block a user