Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWBitVec

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

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.

Persistence

Simple

Example

#include <rw/bitvec.h>
#include <rw/rstream.h>

main(){
   // Allocate a vector with 20 bits, set to TRUE:
   RWBitVec av(20, TRUE);

   av(0) = FALSE;     // Turn bit 0 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
}

Program output:

   [
    0 1 1 1 1 1 1 0 1 1 1 0 0 0 0 1 1 1 1 1
   ]

Public Constructors

RWBitVec();
RWBitVec(size_t N);
RWBitVec(size_t N, RWBoolean initVal);
RWBitVec(const RWByte* bp, size_t N);
RWBitVec(const RWBitVec& v);

Public Destructor

~RWBitVec();

Assignment Operators

RWBitVec&
operator=(const RWBitVec& v);
RWBitVec&
operator=(RWBoolean b);
RWBitVec&
operator&=(const RWBitVec& v);
RWBitVec&
operator^=(const RWBitVec& v);
RWBitVec&
operator|=(const RWBitVec& v);

Indexing Operators

RWBitRef
operator[](size_t i);
RWBitRef
operator()(size_t i);
RWBoolean
operator[](size_t i) const;
RWBoolean
operator()(size_t i) const;

Logical Operators

RWBoolean
operator==(const RWBitVec& u) const;
RWBoolean
operator!=(const RWBitVec& u) const;
RWBoolean
operator==(RWBoolean b) const;
RWBoolean
operator!=(RWBoolean b) const;

Public Member Functions

void
clearBit(size_t i);
const RWByte*
data() const;
size_t
firstFalse() const;
size_t
firstTrue() const;
unsigned
hash() const;
RWBoolean
isEqual(const RWBitVec& v) const;
size_t
length() const;
ostream&
printOn(ostream& s) const;
void
resize(size_t N);
istream&
scanFrom(istream&);
void
setBit(size_t i);
RWBoolean
testBit(size_t i) const;

Related Global Functions

RWBitVec
operator!(const RWBitVec& v);
RWBitVec
operator&(const RWBitVec&,const RWBitVec&);
RWBitVec
operator^(const RWBitVec&,const RWBitVec&);
RWBitVec
operator|(const RWBitVec&,const RWBitVec&);
ostream&
operator<<(ostream& s, const RWBitVec& v);
istream&
operator>>(istream& s, RWBitVec& v);
RWvostream&
operator<<(RWvostream&, const RWBitVec& vec);
RWFile&
operator<<(RWFile&,     const RWBitVec& vec);
RWvistream&
operator>>(RWvistream&, RWBitVec& vec);
RWFile&
operator>>(RWFile&,     RWBitVec& vec);
size_t
sum(const RWBitVec& v);


Previous fileTop of documentContentsIndexNext file
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.