本文整理汇总了C++中BitVector::SetBits方法的典型用法代码示例。如果您正苦于以下问题:C++ BitVector::SetBits方法的具体用法?C++ BitVector::SetBits怎么用?C++ BitVector::SetBits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitVector
的用法示例。
在下文中一共展示了BitVector::SetBits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Test_bitVectorSetAndClearBits
void BitVector_Test::Test_bitVectorSetAndClearBits()
{
BitVector<256>* bits;
bits = setup();
assertUnchanged(0,7);
bits->ClearBits(0,64);
assertUnchanged(2,7);
assert(bits->Read(0,32) == 0);
assert(bits->Read(32,32) == 0);
bits->SetBits(48,64); // hits 1,2,3
assert(bits->Read(0,32) == 0);
assert(bits->Read(32,32) == 0x0000ffff);
assert(bits->Read(64,32) == 0xffffffff);
assert(bits->Read(96,32) == 0xffffdef0);
bits = setup();
bits->ClearBits(31,33); // 0,1; unaligned start, aligned end
assert(bits->Read(0,32) == 0x24681356);
assert(bits->Read(32,32) == 0x0);
assertUnchanged(2,7);
bits = setup();
bits->ClearBits(128,32+32+32+1); // 4-7; aligned start, unaligned end
assertUnchanged(0,3);
assert(bits->Read(128,32) == 0x0);
assert(bits->Read(160,32) == 0x0);
assert(bits->Read(192,32) == 0x0);
assert(bits->Read(224,32) == 0x7edbca09);
bits = setup();
bits->SetBits(128,32+32+32+32); // 4-6; aligned start, aligned end
assertUnchanged(0,3);
assert(bits->Read(128,32) == 0xffffffff);
assert(bits->Read(160,32) == 0xffffffff);
assert(bits->Read(192,32) == 0xffffffff);
assertUnchanged(7,7);
bits = setup();
bits->SetBits(100,48); // 3-4; unaligned start, unaligned end, adjacent
assertUnchanged(0,2);
assert(bits->Read( 96,32) == 0x9fffffff);
assert(bits->Read(128,32) == 0xfffffba9);
assertUnchanged(5,7);
bits = setup();
bits->ClearBits(4,48); // 0-1; unaligned start&end, adjacent, first unit
assert(bits->Read( 0,32) == 0x20000000);
assert(bits->Read( 32,32) == 0x00000314);
assertUnchanged(2,7);
bits = setup();
bits->ClearBits(192+16,32); // 6-7; unaligned start&end, adjacent, last unit
assertUnchanged(0,5);
assert(bits->Read(192,32) == 0x44330000);
assert(bits->Read(224,32) == 0x0000ca09);
bits = setup();
bits->ClearBits(32+16,32*5); // 1-6; unaligned start&end, non-adjacent
assertUnchanged(0,0);
assert(bits->Read( 32,32) == 0x11120000);
assert(bits->Read( 64,32) == 0x00000000);
assert(bits->Read( 96,32) == 0x00000000);
assert(bits->Read(128,32) == 0x00000000);
assert(bits->Read(160,32) == 0x00000000);
assert(bits->Read(192,32) == 0x00002211);
assertUnchanged(7,7);
bits = setup();
bits->ClearBits(16,32*7); // 0-7; unaligned start&end, all units
assert(bits->Read( 0,32) == 0x24680000);
assert(bits->Read( 32,32) == 0x00000000);
assert(bits->Read( 64,32) == 0x00000000);
assert(bits->Read( 96,32) == 0x00000000);
assert(bits->Read(128,32) == 0x00000000);
assert(bits->Read(160,32) == 0x00000000);
assert(bits->Read(192,32) == 0x00000000);
assert(bits->Read(224,32) == 0x0000ca09);
bits = setup();
bits->ClearBits(0,32*8); // 0-7; all bits cleared
for (u32 i = 0; i < 32*8; i += 32)
assert(bits->Read(i,32) == 0x00000000);
bits->SetBits(0,32*8); // 0-7; all bits set
for (u32 i = 0; i < 32*8; i += 32)
assert(bits->Read(i,32) == 0xffffffff);
}