23 #include <openbabel/babelconfig.h> 28 #if defined(_MSC_VER) && _MSC_VER <= 1600 30 typedef unsigned uint32_t;
42 #define WORDSIZE_OF_BITSIZE( bit_size ) ( ( bit_size >> WORDROLL ) + (( bit_size & WORDMASK ) ? 1 : 0) ) 75 { _size = _set.size(); }
84 { _size = _set.size(); }
94 void SetBitOn(
unsigned bit_offset);
96 void SetBitOff(
unsigned bit_offset);
98 void SetRangeOn(
unsigned lo_bit_offset,
unsigned hi_bit_offset);
100 void SetRangeOff(
unsigned lo_bit_offset,
unsigned hi_bit_offset);
102 void Fold(
unsigned new_bit_size);
110 return (BitIsSet(bit_offset) ? 0 : NextBit(bit_offset));
113 int NextBit(
int last_bit_offset)
const;
119 unsigned CountBits()
const;
122 bool IsEmpty()
const;
139 if (size_in_words <= _size)
141 _set.resize(size_in_words, 0);
153 unsigned word_offset = bit_offset >>
WORDROLL;
154 if (word_offset < GetSize())
157 rtn = (( _set[word_offset] >> bit_offset ) & 1);
162 void FromVecInt(
const std::vector<int> & bit_offsets);
164 void FromString(
const std::string & line,
int bits);
166 void ToVecInt(std::vector<int> & bit_offsets)
const;
176 for (word_vector::iterator wx = _set.begin(), wy = _set.end(); wx != wy; ++wx)
186 vec.insert(vec.end(), _set.begin(),_set.end());
200 SetBitOn(bit_offset);
214 bool operator[] (
int bit_offset)
const 215 {
return BitIsSet(bit_offset); }
241 #endif // OB_BITVEC_H OBBitVec()
Construct a bit vector of the default size.
Definition: bitvec.h:73
#define WORDSIZE_OF_BITSIZE(bit_size)
Definition: bitvec.h:42
#define WORDROLL
Definition: bitvec.h:38
OBBitVec operator &(const OBBitVec &bv1, const OBBitVec &bv2)
Definition: bitvec.cpp:487
bool operator<(const OBBitVec &bv1, const OBBitVec &bv2)
Definition: bitvec.cpp:556
bool Resize(unsigned size_in_bits)
Reserve space for size_in_bits bits.
Definition: bitvec.h:128
bool BitIsSet(unsigned bit_offset) const
Asks if the bit_offset 'th bit is set.
Definition: bitvec.h:150
void Negate()
Inverts every bit in the vector.
Definition: bitvec.h:174
OBBitVec operator|(const OBBitVec &bv1, const OBBitVec &bv2)
Definition: bitvec.cpp:475
bool ResizeWords(unsigned size_in_words)
Reserve space for size_in_words words.
Definition: bitvec.h:137
OBBitVec(const OBBitVec &bv)
Copy constructor (result has same number of bits)
Definition: bitvec.h:90
#define STARTWORDS
Definition: bitvec.h:45
A speed-optimized vector of bits.
Definition: bitvec.h:57
vector3 operator-(const vector3 &v1, const vector3 &v2)
Vector subtraction.
Definition: vector3.h:320
size_t GetSize() const
Return the number of words ( NOT the number of bits ).
Definition: bitvec.h:117
OBBitVec(unsigned size_in_bits)
Construct a bit vector of maxbits bits.
Definition: bitvec.h:82
OBBitVec operator^(const OBBitVec &bv1, const OBBitVec &bv2)
Definition: bitvec.cpp:499
void GetWords(word_vector &vec)
Return a copy of the internal vector of words, at the end of vec.
Definition: bitvec.h:184
#define WORDMASK
Definition: bitvec.h:40
double Tanimoto(const OBBitVec &bv1, const OBBitVec &bv2)
The Tanimoto coefficient, which may be regarded as the proportion of the "on-bits" which are shared...
Definition: bitvec.cpp:660
std::ostream & operator<<(std::ostream &, const vector3 &)
Prints a representation of the vector as a row vector of the form "<0.1,1,2>".
Definition: vector3.cpp:109
std::istream & operator>>(std::istream &is, OBBitVec &bv)
Definition: bitvec.cpp:592
int EndBit() const
Return the bit offset of the last bit (for iterating) i.e. -1.
Definition: bitvec.h:115
std::vector< uint32_t > word_vector
Definition: bitvec.h:60
int FirstBit(unsigned bit_offset=0) const
Find the first true bit at or after bit_offset.
Definition: bitvec.h:108
bool operator==(const OBBitVec &bv1, const OBBitVec &bv2)
Definition: bitvec.cpp:525
Global namespace for all Open Babel code.
Definition: alias.h:22