OBBitVec Class Reference

Fast and efficient bitstring class. More...

#include <openbabel/bitvec.h>

List of all members.

Public Member Functions

 OBBitVec ()
 OBBitVec (int bits)
 OBBitVec (const OBBitVec &)
void SetBitOn (int)
void SetBitOff (int)
void SetRangeOn (int, int)
void SetRangeOff (int, int)
void Fold (int)
int FirstBit (int index=0)
int NextBit (int)
int EndBit ()
int GetSize () const
int CountBits ()
bool Empty ()
bool IsEmpty ()
bool Resize (int maxbits)
bool BitIsSet (int bit)
bool BitIsOn (int bit)
void FromVecInt (std::vector< int > &)
void FromString (std::string &, int)
void ToVecInt (std::vector< int > &)
void Clear (void)
void Negate ()
OBBitVecoperator= (const OBBitVec &)
OBBitVecoperator &= (OBBitVec &)
OBBitVecoperator|= (OBBitVec &)
OBBitVecoperator|= (const int i)
OBBitVecoperator^= (OBBitVec &)
OBBitVecoperator-= (OBBitVec &)
OBBitVecoperator+= (OBBitVec &bv)
bool operator[] (int bit)
void GetWords (std::vector< unsigned int > &vec)

Friends

OBBitVec operator| (OBBitVec &, OBBitVec &)
OBBitVec operator & (OBBitVec &, OBBitVec &)
OBBitVec operator^ (OBBitVec &, OBBitVec &)
OBBitVec operator- (OBBitVec &, OBBitVec &)
bool operator== (const OBBitVec &, const OBBitVec &)
bool operator< (const OBBitVec &bv1, const OBBitVec &bv2)
std::istream & operator>> (std::istream &, OBBitVec &)
std::ostream & operator<< (std::ostream &, const OBBitVec &)


Detailed Description

Fast and efficient bitstring class.

The OBBitVec class is a fast and efficient bitstring class that is handy to use as a truth table. Truth tables are an easy way to store whether a list of items has a particular propery. Instances of OBBitVec can by dynamically resized, and have a number of overloaded operators that make code simple and readable. The following examples demonstrate uses of the OBBitVec class:

    OBBitVec bv1,bv2,bv3;
    bv1.SetBitOn(5);
    bv2.SetBitOff(200);
    bv1 |= bv2;
    bv1 = bv1 & bv2;
    if (bv1.Empty()) //Empty() returns true if no bits are set on
    {
       cout << "bv1 = " << bv1 << endl;
    }

    int bit;
    for (bit = bv1.NextBit(0);bit != bv1.EndBit();bit = bv1.NextBit(bit))
    {
       cout << "the next bit turned on is " << bit << endl;
    }


Constructor & Destructor Documentation

OBBitVec (  )  [inline]

OBBitVec ( int  bits  )  [inline]

OBBitVec ( const OBBitVec  ) 

Copy constructor (result has same number of bits).


Member Function Documentation

void SetBitOn ( int   ) 

void SetBitOff ( int   ) 

void SetRangeOn ( int  ,
int   
)

void SetRangeOff ( int  ,
int   
)

void Fold ( int   ) 

int FirstBit ( int  index = 0  )  [inline]

Returns:
the index of the first bit past index that is set to true
Parameters:
index the first bit to consider

int NextBit ( int   ) 

int EndBit (  )  [inline]

Returns:
the index of the last bit (for iterating)

int GetSize (  )  const [inline]

Returns:
number of 32 bit words. NOT number of bits.

int CountBits (  ) 

Returns:
the number of bits

bool Empty (  )  [inline]

Deprecated:
Use IsEmpty() instead.

bool IsEmpty (  ) 

bool Resize ( int  maxbits  ) 

Number of bits increased if necessary but never decreased.

bool BitIsSet ( int  bit  )  [inline]

bool BitIsOn ( int  bit  )  [inline]

void FromVecInt ( std::vector< int > &   ) 

void FromString ( std::string &  ,
int   
)

void ToVecInt ( std::vector< int > &   ) 

void Clear ( void   ) 

void Negate (  )  [inline]

Inverts every bit in the vector.

OBBitVec & operator= ( const OBBitVec  ) 

Assignment operator but number of bits is not reduced.

OBBitVec & operator &= ( OBBitVec  ) 

OBBitVec & operator|= ( OBBitVec  ) 

OBBitVec& operator|= ( const int  i  )  [inline]

OBBitVec & operator^= ( OBBitVec  ) 

OBBitVec & operator-= ( OBBitVec  ) 

OBBitVec & operator+= ( OBBitVec bv  ) 

bool operator[] ( int  bit  )  [inline]

void GetWords ( std::vector< unsigned int > &  vec  )  [inline]

Access to data in word size pieces CM.


Friends And Related Function Documentation

OBBitVec operator| ( OBBitVec bv1,
OBBitVec bv2 
) [friend]

OBBitVec operator & ( OBBitVec bv1,
OBBitVec bv2 
) [friend]

OBBitVec operator^ ( OBBitVec bv1,
OBBitVec bv2 
) [friend]

OBBitVec operator- ( OBBitVec bv1,
OBBitVec bv2 
) [friend]

bool operator== ( const OBBitVec bv1,
const OBBitVec bv2 
) [friend]

bool operator< ( const OBBitVec bv1,
const OBBitVec bv2 
) [friend]

std::istream& operator>> ( std::istream &  is,
OBBitVec bv 
) [friend]

std::ostream& operator<< ( std::ostream &  os,
const OBBitVec bv 
) [friend]


The documentation for this class was generated from the following files: