Tools.h++ Manual

21-24 104011 Tandem Computers Incorporated
21
RWBitVec
Synopsis
#include <rw/bitvec.h>
RWBitVec v;
Description Class
RWBitVec
is a bitvector whose length can be changed at run time.
Because this requires an extra level of indirection, this makes it slightly less
efficient than classes
RWGBitVec
(size) or
RWTBitVec
<size>, whose lengths are
fixed at compile time.
Example
Program output:
[
1 1 1 1 1 1 1 0 1 1 1 0 0 0 0 1 1 1 1 1
]
#include <rw/bitvec.h>
#include <rw/rstream.h>
main()
{
// Allocate a vector with 20 bits, set to TRUE:
RWBitVec av(20, TRUE);
av(2) = FALSE; // Turn bit 2 off
av.clearBit(7); // Turn bit 7 off
av.setBit(2); // Turn bit 2 back on
for(int i=11; i<=14; i++) av(i) = FALSE;
cout << av << endl; // Print the vector out}
}