(Bitset) Added Unbounded methods

Former-commit-id: 898eecf4aa8ecf7c9ec85fc8c46c17a6c3badc34
This commit is contained in:
Lynix 2015-03-16 19:21:28 +01:00
parent 6b799b1887
commit 860712b09f
2 changed files with 32 additions and 0 deletions

View File

@ -70,6 +70,10 @@ class NzBitset
template<typename T> T To() const;
NzString ToString() const;
void UnboundedReset(unsigned int bit);
void UnboundedSet(unsigned int bit, bool val = true);
bool UnboundedTest(unsigned int bit) const;
Bit operator[](int index);
bool operator[](int index) const;

View File

@ -379,6 +379,34 @@ NzString NzBitset<Block, Allocator>::ToString() const
return str;
}
template<typename Block, class Allocator>
void NzBitset<Block, Allocator>::UnboundedReset(unsigned int bit)
{
UnboundedSet(bit, false);
}
template<typename Block, class Allocator>
void NzBitset<Block, Allocator>::UnboundedSet(unsigned int bit, bool val)
{
if (bit < m_bitCount)
Set(bit, val);
else if (val)
{
// On élargit le bitset seulement s'il y a un bit à marquer
Resize(bit + 1, false);
Set(bit, true);
}
}
template<typename Block, class Allocator>
bool NzBitset<Block, Allocator>::UnboundedTest(unsigned int bit) const
{
if (bit < m_bitCount)
return Test(bit);
else
return false;
}
template<typename Block, class Allocator>
typename NzBitset<Block, Allocator>::Bit NzBitset<Block, Allocator>::operator[](int index)
{