Tools.h++ Manual
23-2 104011 Tandem Computers Incorporated
23
Example In this example, a bit vector 24 bits long is declared and exercised:
Public constructors
RWGBitVec(
size
)();
Construct a bit vector size elements long, with all bits initialized to
FALSE
.
RWGBitVec(
size
)(RWBoolean f);
Construct a bit vector size elements long, with all bits initialized to
f
.
RWGBitVec(
size
)(unsigned long v);
Construct a bit vector size elements long, initialized to the bits of
v
. If size is
greater than
sizeof(v)
, the extra bits will be set to zero.
Assignment operators
RWGBitVec(sz)& operator=(const RWGBitVec(sz)&
v);
Set each element of self to the corresponding bit value of
v
. Return a reference
to self.
RWGBitVec(sz)& operator=(RWBoolean f);
Set all elements of self to the boolean value f.
RWGBitVec(sz)& operator&=(const RWGBitVec(sz)&
v);
RWGBitVec(sz)& operator^=(const RWGBitVec(sz)&
v);
RWGBitVec(sz)& operator|=(const RWGBitVec(sz)&
v);
#include <rw/gbitvec.h>
declare(RWGBitVec,24) // declare a 24 bit long vector
implement(RWGBitVec, 24) // implement the vector
main()
{
RWGBitVec(24) a, b; // Allocate two vectors.
a(2) = TRUE; // Set bit 2 (the third bit) of
a on.
b(3) = TRUE; // Set bit 3 (the fourth bit
of b on.
RWGBitVec(24) c = a ^ b; // Set c to the XOR of a and b.
}