Added SetOnes() and SetZeros()

This commit is contained in:
Bart Trzynadlowski 2017-09-23 16:08:27 +00:00
parent c3eef706e8
commit 3041ca1922
2 changed files with 18 additions and 0 deletions

View file

@ -210,12 +210,26 @@ namespace Util
Insert(0, value);
}
void BitRegister::SetZeros()
{
if (Empty())
return;
memset(m_bits.data(), 0, m_bits.size());
}
void BitRegister::SetZeros(size_t count)
{
m_bits.resize(count);
memset(m_bits.data(), 0, count);
}
void BitRegister::SetOnes()
{
if (Empty())
return;
memset(m_bits.data(), 1, m_bits.size());
}
void BitRegister::SetOnes(size_t count)
{
m_bits.resize(count);

View file

@ -41,6 +41,10 @@ namespace Util
// Functions that insert bits, clipped against current register size
void SetBit(size_t bitPos, uint8_t value);
void Insert(size_t bitPos, const std::string &value);
// Functions that reset the contents but not the size of the register
void SetZeros();
void SetOnes();
// Functions that reset the contents (and size) of the register
void Set(const std::string &value);