45#ifndef UTILS_OPENMDBITSET_HPP 
   46#define UTILS_OPENMDBITSET_HPP 
   70    void flip(
size_t bitIndex) { bitset_[bitIndex] = !bitset_[bitIndex]; }
 
   74    void flip(
size_t fromIndex, 
size_t toIndex);
 
   80    bool get(
size_t bitIndex) { 
return bitset_[bitIndex]; }
 
   92    int firstOffBit()
 const { 
return !bitset_[0] ? 0 : 
nextOffBit(0); }
 
  101    int firstOnBit()
 const { 
return bitset_[0] ? 0 : 
nextOnBit(0); }
 
  108    int nthOnBit(
unsigned long int n) 
const;
 
  120    void setBitOn(
size_t bitIndex) { setBit(bitIndex, 
true); }
 
  122    void setBitOff(
size_t bitIndex) { setBit(bitIndex, 
false); }
 
  124    void setRangeOn(
size_t fromIndex, 
size_t toIndex) {
 
  125      setBits(fromIndex, toIndex, 
true);
 
  128    void setRangeOff(
size_t fromIndex, 
size_t toIndex) {
 
  129      setBits(fromIndex, toIndex, 
false);
 
  135    void setAll() { setRangeOn(0, 
size()); }
 
  139    size_t size()
 const { 
return bitset_.size(); }
 
  142    void resize(
size_t nbits);
 
  148    OpenMDBitSet& operator|=(
const OpenMDBitSet& bs) {
 
  152    OpenMDBitSet& operator^=(
const OpenMDBitSet& bs) {
 
  156    OpenMDBitSet& operator-=(
const OpenMDBitSet& bs) {
 
  157      OpenMDBitSet tmp = *
this ^ bs;
 
  162    OpenMDBitSet parallelReduce();
 
  164    bool operator[](
int bitIndex)
 const { 
return bitset_[bitIndex]; }
 
  165    friend OpenMDBitSet operator|(
const OpenMDBitSet& bs1,
 
  166                                  const OpenMDBitSet& bs2);
 
  167    friend OpenMDBitSet operator&(
const OpenMDBitSet& bs1,
 
  168                                  const OpenMDBitSet& bs2);
 
  169    friend OpenMDBitSet operator^(
const OpenMDBitSet& bs1,
 
  170                                  const OpenMDBitSet& bs2);
 
  171    friend OpenMDBitSet operator-(
const OpenMDBitSet& bs1,
 
  172                                  const OpenMDBitSet& bs2);
 
  174    friend bool operator==(
const OpenMDBitSet& bs1, 
const OpenMDBitSet& bs2);
 
  177    friend std::ostream& operator<<(std::ostream&, 
const OpenMDBitSet& bs);
 
  181    void setBit(
size_t bitIndex, 
bool value) { bitset_[bitIndex] = value; }
 
  185    void setBits(
size_t fromIndex, 
size_t toIndex, 
bool value);
 
  187    std::vector<bool> bitset_;
 
 
OpenMDBitSet is a wrapper class of std::vector<bool> to act as a growable std::bitset.
 
bool any()
Returns true if any bits are set to true.
 
void andOperator(const OpenMDBitSet &bs)
Performs a logical AND of this target bit set with the argument bit set.
 
void clearAll()
Sets all of the bits in this OpenMDBitSet to false.
 
void flip(size_t bitIndex)
Sets the bit at the specified index to to the complement of its current value.
 
void flip()
Sets each bit to the complement of its current value.
 
bool none()
Returns true if no bits are set to true.
 
void resize(size_t nbits)
Changes the size of OpenMDBitSet.
 
int countBits()
Returns the number of bits set to true in this OpenMDBitSet.
 
size_t size() const
Returns the number of bits of space actually in use by this OpenMDBitSet to represent bit values.
 
int nextOnBit(int fromIndex) const
Returns the index of the first bit that is set to true that occurs on or after the specified starting...
 
bool get(size_t bitIndex)
Returns the value of the bit with the specified index.
 
void xorOperator(const OpenMDBitSet &bs)
Performs a logical XOR of this bit set with the bit set argument.
 
int nthOffBit(unsigned long int n) const
Returns the index of the n^th bit that is set to false.
 
int nextOffBit(int fromIndex) const
Returns the index of the first bit that is set to false that occurs on or after the specified startin...
 
void orOperator(const OpenMDBitSet &bs)
Performs a logical OR of this bit set with the bit set argument.
 
int nthOnBit(unsigned long int n) const
Returns the index of the n^th bit that is set to true.
 
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.