本文整理汇总了C++中BitVector::Read方法的典型用法代码示例。如果您正苦于以下问题:C++ BitVector::Read方法的具体用法?C++ BitVector::Read怎么用?C++ BitVector::Read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitVector
的用法示例。
在下文中一共展示了BitVector::Read方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Test_bitVectorCtors
void BitVector_Test::Test_bitVectorCtors()
{
{
BitVector<10> bv;
assert(bv.Read(0,10)==0);
}
{
BitVector<30> bv;
assert(bv.Read(0,30)==0);
}
{
BitVector<60> bv;
assert(bv.ReadLong(0,60)==0);
}
{
BitVector<12> bv(0x1234);
assert(bv.Read(0,12)==0x234);
}
{
BitVector<30> bv(0xdeadbeef);
assert(bv.Read(0,30)==0x1eadbeef);
}
{
BitVector<60> bv(0xdeadbeef);
assert(bv.ReadLong(0,60)==0xdeadbeef);
}
}
示例2: Test_bitVectorWrite
void BitVector_Test::Test_bitVectorWrite()
{
BitVector<256>* bits = setup();
bits->Write(16, 32, 0xa0a0b0b0);
assert(bits->Read(0, 32) == 0x2468a0a0);
assert(bits->Read(32, 32) == 0xb0b01314);
assert(bits->Read(224, 32) == 0xfedbca09);
}
示例3: Test_bitVectorRead
void BitVector_Test::Test_bitVectorRead()
{
BitVector<256>* bits = setup();
assert(bits->Read(16, 32) == 0x13571112);
assert(bits->Read(64, 32) == 0x12345678);
assert(bits->Read(56, 16) == 0x00001412);
{
BitVector<64> foo;
assert(foo.Read(64-31, 31)==0);
}
}
示例4: Test_bitVectorSplitWrites
void BitVector_Test::Test_bitVectorSplitWrites()
{
BitVector<64> bits;
// Nothing in there to start
assert(bits.Read(0,32) == 0);
assert(bits.Read(32,32) == 0);
// Write four bits in bottom of 0 and 12 into top of 1
bits.Write(28,16,0x1234);
assert(bits.Read(0,32) == 0x1);
assert(bits.Read(32,32) == 0x23400000);
}
示例5: Test_bitVectorRead
void BitVector_Test::Test_bitVectorRead()
{
BitVector<256>* bits = setup();
assert(bits->Read(16, 32) == 0x13571112);
assert(bits->Read(64, 32) == 0x12345678);
assert(bits->Read(56, 16) == 0x00001412);
{
BitVector<64> foo;
assert(foo.Read(64-31, 31)==0);
}
{
BV96 foo;
foo = bits->ReadBig(0,96);
assert(foo.Read(0, 32) == 0x24681357);
assert(foo.Read(32, 32) == 0x11121314);
assert(foo.Read(64, 32) == 0x12345678);
foo = bits->ReadBig(160,96);
assert(foo.Read(0, 32) == 0x87654321);
assert(foo.Read(32, 32) == 0x44332211);
assert(foo.Read(64, 32) == 0xfedbca09);
}
{
BV96 foo;
foo = bits->ReadBig(0,32);
assert(foo.Read(0, 32) == 0x24681357);
assert(foo.Read(32, 32) == 0);
assert(foo.Read(64, 32) == 0);
foo = bits->ReadBig(160,64);
assert(foo.Read(0, 32) == 0x87654321);
assert(foo.Read(32, 32) == 0x44332211);
assert(foo.Read(64, 32) == 0);
}
}
示例6: Test_RunTests
void BitVector_Test::Test_RunTests() {
{
BitVector<0> zeroSizeShouldCompileOK;
assert(sizeof(zeroSizeShouldCompileOK) * 8 == BitVector<256>::BITS_PER_UNIT);
assert(zeroSizeShouldCompileOK.Read(0, 0) == 0); // Only legal read args
zeroSizeShouldCompileOK.Write(0, 0, 0x87654321); // Ignored
assert(zeroSizeShouldCompileOK.Read(0, 0) == 0); // Still nothing there
}
Test_bitVectorCtors();
Test_bitVectorLong();
Test_bitVectorAllocate();
Test_bitVectorRead();
Test_bitVectorSize();
Test_bitVectorWrite();
Test_bitVectorSplitWrites();
Test_bitVectorSetAndClearBits();
Test_bitVectorStoreBits();
Test_bitVectorReadWriteBV();
Test_bitVectorPopulationCount();
}
示例7: Test_bitVectorStoreBits
void BitVector_Test::Test_bitVectorStoreBits()
{
const u32 PATTERN = 0xdeadbeef;
BitVector<256>* bits;
bits = setup();
bits->StoreBits(PATTERN,12,32*7); // 0-7; unaligned start/end
assert(bits->Read( 0,32) == 0x246dbeef);
assert(bits->Read( 32,32) == 0xdeadbeef);
assert(bits->Read( 64,32) == 0xdeadbeef);
assert(bits->Read( 96,32) == 0xdeadbeef);
assert(bits->Read(128,32) == 0xdeadbeef);
assert(bits->Read(160,32) == 0xdeadbeef);
assert(bits->Read(192,32) == 0xdeadbeef);
assert(bits->Read(224,32) == 0xdeabca09);
bits = setup();
bits->StoreBits(PATTERN,96,12); // 3-3; single front-aligned
assertUnchanged(0,2);
assert(bits->Read( 96,32) == 0xdeacdef0);
assertUnchanged(4,7);
bits = setup();
bits->StoreBits(PATTERN,96+20,12); // 3-3; single back-aligned
assertUnchanged(0,2);
assert(bits->Read( 96,32) == 0x9abcdeef);
assertUnchanged(4,7);
bits = setup();
bits->StoreBits(PATTERN,96+8,16); // 3-3; single unaligned
assertUnchanged(0,2);
assert(bits->Read( 96,32) == 0x9aadbef0);
assertUnchanged(4,7);
}
示例8: Test_bitVectorReadWriteBV
void BitVector_Test::Test_bitVectorReadWriteBV()
{
BitVector<256> bits; // 0 init
BitVector<4> dig;
BitVector<32> dug;
for (u32 i = 0; i <16; ++i)
{
dig.Write(0,4,i);
bits.WriteBV(i*4, dig);
}
bits.ReadBV(0, dug);
assert(dug.Read( 0,32) == 0x01234567);
bits.ReadBV(32, dug);
assert(dug.Read( 0,32) == 0x89abcdef);
bits.ReadBV(48, dug);
assert(dug.Read( 0,32) == 0xcdef0000);
BitVector<100> big;
bits.ReadBV(0, big);
big.Write(100 - 4, 4, 0xe);
bits.WriteBV(4,big);
bits.WriteBV(128,big);
assert(bits.Read( 0,32) == 0x00123456);
assert(bits.Read( 32,32) == 0x789abcde);
assert(bits.Read( 64,32) == 0xf0000000);
assert(bits.Read( 96,32) == 0x0e000000);
assert(bits.Read(128,32) == 0x01234567);
assert(bits.Read(160,32) == 0x89abcdef);
assert(bits.Read(192,32) == 0x00000000);
assert(bits.Read(224,32) == 0xe0000000);
}
示例9: 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);
}
示例10: assertUnchanged
static void assertUnchanged(u32 firstIdx, u32 lastIdx) {
for (u32 i = firstIdx; i < lastIdx; ++i)
assert(bits.Read(i*32,32) == vals[i]);
}
示例11: Test_bitVectorAllocate
void BitVector_Test::Test_bitVectorAllocate()
{
BitVector<256>* bits = setup();
assert(bits->Read(0, 32) == 0x24681357);
}
示例12: Test_bitVectorWrite
void BitVector_Test::Test_bitVectorWrite()
{
BitVector<256>* bits = setup();
bits->Write(16, 32, 0xa0a0b0b0);
assert(bits->Read(0, 32) == 0x2468a0a0);
assert(bits->Read(32, 32) == 0xb0b01314);
assert(bits->Read(224, 32) == 0xfedbca09);
// WriteBig
{
BitVector<256>* bb = setup();
u32 fooBits[] = {0xabc123ee,0x55667788,0x01020304};
BV96 foo(fooBits);
bb->WriteBig(0,32,foo);
assert(bits->Read(0, 32) == 0xabc123ee);
assert(bits->Read(32, 32) == 0x11121314);
assert(bits->Read(64, 32) == 0x12345678);
bb->WriteBig(64,64,foo);
assert(bits->Read(0, 32) == 0xabc123ee);
assert(bits->Read(32, 32) == 0x11121314);
assert(bits->Read(64, 32) == 0xabc123ee);
assert(bits->Read(96, 32) == 0x55667788);
assert(bits->Read(128, 32) == 0x0fedcba9);
bb->WriteBig(32,96,foo);
assert(bits->Read(0, 32) == 0xabc123ee);
assert(bits->Read(32, 32) == 0xabc123ee);
assert(bits->Read(64, 32) == 0x55667788);
assert(bits->Read(96, 32) == 0x01020304);
assert(bits->Read(128, 32) == 0x0fedcba9);
}
}