Tools.h++ Manual

21-28 104011 Tandem Computers Incorporated
21
void setBit(size_t i);// Set bit i
Sets (i.e., sets to
TRUE
) the bit with index
i
. The index
i
must be between 0
and size–1. No bounds checking is performed. The following are equivalent,
although
setBit(size_t)
is slightly smaller and faster than using
operator()(size_t)
:
a(i) = TRUE;
a.setBit(i);
RWBoolean testBit(size_t i) const;
Tests the bit with index
i
. The index
i
must be between 0 and size–1. No
bounds checking is performed. The following are equivalent, although
testBit(size_t)
is slightly smaller and faster than using
operator()(size_t)
:
if( a(i) ) doSomething();
if( a.testBit(i) ) doSomething();
Related global functions
RWBitVec operator!(const RWBitVec& v);
Unary operator that returns the logical negation of vector
v
.
RWBitVec operator&(const RWBitVec&,const RWBitVec&);
RWBitVec operator^(const RWBitVec&,const RWBitVec&);
RWBitVec operator|(const RWBitVec&,const RWBitVec&);
Returns a vector that is the logical AND, XOR, or OR of the vectors
v1
and
v2
.
The two vectors must have the same length or an exception of type
RWInternalErr
will occur.
ostream& operator<<(ostream& s, const RWBitVec& v);
Calls
v.printOn(s)
.
istream& operator>>(istream& s, RWBitVec& v);
Calls
v.scanFrom(s)
.
RWvostream& operator<<(RWvostream&, const
RWBitVec& vec);
RWFile& operator<<(RWFile&, const
RWBitVec& vec);
Saves the
RWBitVec vec
to a virtual stream or
RWFile
, respectively.