11#ifndef __RD_SPARSEBITVECTS_H__
12#define __RD_SPARSEBITVECTS_H__
39 explicit SparseBitVect(
unsigned int size) : dp_bits(nullptr), d_size(0) {
49 std::copy(bv->begin(), bv->end(), std::inserter(*dp_bits, dp_bits->end()));
59 bool operator[](
const unsigned int which)
const override;
68 unsigned int getNumBits()
const override {
return d_size; }
69 bool setBit(
const unsigned int which)
override;
71 bool unsetBit(
const unsigned int which)
override;
72 bool getBit(
const unsigned int which)
const override;
77 return static_cast<unsigned int>(dp_bits->size());
80 return d_size -
static_cast<unsigned int>(dp_bits->size());
98 unsigned int d_size{0};
99 void _initForSize(
const unsigned int size)
override;
100 bool checkIndex(
const unsigned int idx)
const {
101 return idx < d_size || (idx == d_size &&
102 d_size == std::numeric_limits<unsigned int>::max());
104 template <
typename T>
105 bool checkIndex(
const T which)
const {
106 return *which >= 0 &&
static_cast<unsigned int>(*which) < d_size;
std::vector< int > IntVect
IntVect::iterator IntVectIter
IntSet::iterator IntSetIter
IntSet::const_iterator IntSetConstIter
Abstract base class for storing BitVectors.
a class for bit vectors that are sparsely occupied.
bool setBit(const unsigned int which) override
sets a particular bit and returns its original value
unsigned int getNumOffBits() const override
returns the number of off bits
bool getBit(const IntSetIter which) const
unsigned int getNumBits() const override
returns the number of bits (the length of the BitVect)
SparseBitVect operator|(const SparseBitVect &) const
bool getBit(const unsigned int which) const override
returns the value of a particular bit
void clearBits() override
clears (sets to off) all of our bits
SparseBitVect operator&(const SparseBitVect &) const
~SparseBitVect() override
bool unsetBit(const unsigned int which) override
unsets a particular bit and returns its original value
SparseBitVect & operator=(const SparseBitVect &)
SparseBitVect operator~() const
unsigned int getNumOnBits() const override
returns the number of on bits
void getOnBits(IntVect &v) const override
replaces the contents of v with indices of our on bits
bool operator!=(const SparseBitVect &o) const
SparseBitVect(const char *data, const unsigned int dataLen)
construct from a text pickle
bool setBit(const IntSetIter which)
bool operator[](const unsigned int which) const override
bool operator==(const SparseBitVect &o) const
SparseBitVect operator^(const SparseBitVect &) const
SparseBitVect(unsigned int size)
initialize with a particular size;
IntSet * dp_bits
our raw data, exposed for the sake of efficiency
std::string toString() const override
returns a serialized (pickled) version of this BitVect
bool getBit(const IntVectIter which) const
SparseBitVect(const SparseBitVect &other)
copy constructor
SparseBitVect(const std::string &pkl)
construct from a string pickle
const IntSet * getBitSet() const
returns a (const) pointer to our raw storage
#define RDKIT_DATASTRUCTS_EXPORT