#include <openbabel/bitvec.h>
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 () |
| OBBitVec & | operator= (const OBBitVec &) |
| OBBitVec & | operator &= (OBBitVec &) |
| OBBitVec & | operator|= (OBBitVec &) |
| OBBitVec & | operator|= (const int i) |
| OBBitVec & | operator^= (OBBitVec &) |
| OBBitVec & | operator-= (OBBitVec &) |
| OBBitVec & | operator+= (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 &) |
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; }
| OBBitVec | ( | ) | [inline] |
| OBBitVec | ( | int | bits | ) | [inline] |
| void SetBitOn | ( | int | ) |
| void SetBitOff | ( | int | ) |
| void SetRangeOn | ( | int | , | |
| int | ||||
| ) |
| void SetRangeOff | ( | int | , | |
| int | ||||
| ) |
| void Fold | ( | int | ) |
| int FirstBit | ( | int | index = 0 |
) | [inline] |
index that is set to true | index | the first bit to consider |
| int NextBit | ( | int | ) |
| int EndBit | ( | ) | [inline] |
| int GetSize | ( | ) | const [inline] |
| int CountBits | ( | ) |
| bool Empty | ( | ) | [inline] |
| 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 int | i | ) | [inline] |
| bool operator[] | ( | int | bit | ) | [inline] |
| void GetWords | ( | std::vector< unsigned int > & | vec | ) | [inline] |
Access to data in word size pieces CM.
| std::istream& operator>> | ( | std::istream & | is, | |
| OBBitVec & | bv | |||
| ) | [friend] |
| std::ostream& operator<< | ( | std::ostream & | os, | |
| const OBBitVec & | bv | |||
| ) | [friend] |