本文整理汇总了C++中BitVector::ClearBit方法的典型用法代码示例。如果您正苦于以下问题:C++ BitVector::ClearBit方法的具体用法?C++ BitVector::ClearBit怎么用?C++ BitVector::ClearBit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitVector
的用法示例。
在下文中一共展示了BitVector::ClearBit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Test_bitVectorPopulationCount
void BitVector_Test::Test_bitVectorPopulationCount()
{
{
const u32 SIZE = 0;
BitVector<SIZE> bits;
assert(bits.PopulationCount() == 0);
for (u32 i = 0; i < SIZE; ++i)
{
bits.SetBit(i);
assert(bits.PopulationCount() == i + 1);
}
}
{
const u32 SIZE = 1;
BitVector<SIZE> bits;
assert(bits.PopulationCount() == 0);
for (u32 i = 0; i < SIZE; ++i)
{
bits.SetBit(i);
assert(bits.PopulationCount() == i + 1);
}
}
{
const u32 SIZE = 31;
BitVector<SIZE> bits;
assert(bits.PopulationCount() == 0);
for (u32 i = 0; i < SIZE; ++i)
{
bits.SetBit(i);
assert(bits.PopulationCount() == i + 1);
}
}
{
const u32 SIZE = 32;
BitVector<SIZE> bits;
assert(bits.PopulationCount() == 0);
for (u32 i = 0; i < SIZE; ++i)
{
bits.SetBit(i);
assert(bits.PopulationCount() == i + 1);
}
}
{
const u32 SIZE = 35;
BitVector<SIZE> bits;
assert(bits.PopulationCount() == 0);
for (u32 i = 0; i < SIZE; ++i)
{
bits.SetBit(i);
assert(bits.PopulationCount() == i + 1);
}
}
{
const u32 SIZE = 67;
BitVector<SIZE> bits;
assert(bits.PopulationCount() == 0);
for (u32 i = 0; i < SIZE; ++i)
{
bits.SetBit(i);
assert(bits.PopulationCount() == i + 1);
}
// all combinations of start and len..
BitVector<SIZE> zbits;
for (u32 start = 0; start < SIZE; ++start)
{
for (u32 end = start; end < SIZE; ++end)
{
u32 len = end - start + 1;
assert(bits.PopulationCount(start, len) == len);
assert(zbits.PopulationCount(start, len) == 0);
}
}
}
{
const u32 SIZE = 258;
BitVector<SIZE> bits;
assert(bits.PopulationCount() == 0);
for (u32 i = 0; i < SIZE; ++i)
{
bits.SetBit(SIZE - i - 1);
assert(bits.PopulationCount() == i + 1);
}
assert(bits.PopulationCount() == SIZE);
for (u32 i = 0; i < SIZE; ++i)
{
bits.ClearBit(i);
assert(bits.PopulationCount() == SIZE - (i + 1));
}
}
{
BitVector<256>* bits = setup();
assert(bits->PopulationCount() == 115);
//.........这里部分代码省略.........