AK: Add Bitmap::set_range()

Add set_range() which sets a range of bits to requested value.
Fix code style.
This commit is contained in:
nimelehin 2020-02-28 14:05:22 +03:00 committed by Andreas Kling
parent 6e7713a5f4
commit 73901c9b2b
Notes: sideshowbarker 2024-07-19 07:52:35 +09:00

View file

@ -94,6 +94,12 @@ public:
else
m_data[index / 8] &= static_cast<u8>(~(1u << (index % 8)));
}
void set_range(size_t start, size_t len, bool value)
{
for (size_t index = start; index < start + len; ++index) {
set(index, value);
}
}
u8* data() { return m_data; }
const u8* data() const { return m_data; }
@ -136,8 +142,7 @@ public:
while (i < m_size / 8 && m_data[i] == 0x00)
i++;
size_t j = 0;
for (j = i * 8; j < m_size; j++) {
for (size_t j = i * 8; j < m_size; j++) {
if (get(j))
return j;
}
@ -151,8 +156,7 @@ public:
while (i < m_size / 8 && m_data[i] == 0xff)
i++;
size_t j = 0;
for (j = i * 8; j < m_size; j++)
for (size_t j = i * 8; j < m_size; j++)
if (!get(j))
return j;