beautypg.com

Boolean vectors – HP Integrity NonStop H-Series User Manual

Page 63

background image

Click on the banner to return to the user guide home page.

©Copyright 1996 Rogue Wave Software

Boolean Vectors

Vectors of bit values (boolean 1/0 values) are handled as a special case by the standard library,
so that the values can be efficiently packed (several elements to a word). The operations for a
boolean vector , vector, are a superset of those for an ordinary vector, only the
implementation is more efficient.

One new member function added to the boolean vector data type is flip(). When invoked, this
function inverts all the bits of the vector. Boolean vectors also return as reference an internal
value that also supports the flip() member function.

vector bvec(27);
bvec.flip(); // flip all values
bvec[17].flip(); // flip bit 17

vector also supports an additional swap() member function that allows you to swap the
values indicated by a pair of references.

bvec.swap(bvec [17], bvec [16]);

This manual is related to the following products: