RDKit: SparseBitVect Class Reference

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Public Attributes | List of all members
SparseBitVect Class Reference

a class for bit vectors that are sparsely occupied. More...

`#include <SparseBitVect.h>`

Inheritance diagram for SparseBitVect:

## Public Member Functions
| SparseBitVect ()
| SparseBitVect (unsigned int size)
| initialize with a particular size; More...
| SparseBitVect (const SparseBitVect &other)
| copy constructor More...
| SparseBitVect (const std::string &)
| construct from a string pickle More...
| SparseBitVect (const char *data, const unsigned int dataLen)
| construct from a text pickle More...
SparseBitVect & | operator= (const SparseBitVect &)
| ~SparseBitVect ()
bool | operator[] (const unsigned int which) const
SparseBitVect | operator| (const SparseBitVect &) const
SparseBitVect | operator& (const SparseBitVect &) const
SparseBitVect | operator^ (const SparseBitVect &) const
SparseBitVect | operator~ () const
const IntSet * | getBitSet () const
| returns a (const) pointer to our raw storage More...
unsigned int | getNumBits () const
| returns the number of bits (the length of the BitVect) More...
bool | setBit (const unsigned int which)
| sets a particular bit and returns its original value More...
bool | setBit (const IntSetIter which)
bool | unsetBit (const unsigned int which)
| unsets a particular bit and returns its original value More...
bool | getBit (const unsigned int which) const
| returns the value of a particular bit More...
bool | getBit (const IntVectIter which) const
bool | getBit (const IntSetIter which) const
unsigned int | getNumOnBits () const
| returns the number of on bits More...
unsigned int | getNumOffBits () const
| returns the number of off bits More...
std::string | toString () const
| returns a serialized (pickled) version of this BitVect More...
void | getOnBits (IntVect &v) const
| replaces the contents of `v` with indices of our on bits More...
void | clearBits ()
| clears (sets to off) all of our bits More...
bool | operator== (const SparseBitVect &o) const
bool | operator!= (const SparseBitVect &o) const
Public Member Functions inherited from BitVect
virtual | ~BitVect ()=0
void | initFromText (const char *data, const unsigned int dataLen, bool isBase64=false, bool allowOldFormat=false)
| initializes this BitVect from a pickle More...
unsigned int | size () const

## Public Attributes
IntSet * | dp_bits
| our raw data, exposed for the sake of efficiency More...

## Detailed Description

a class for bit vectors that are sparsely occupied.

SparseBitVect objects store only their on bits, in an std::set.

They are, as you might expect, quite memory efficient for sparsely populated vectors but become rather a nightmare if they need to be negated.

Definition at line 33 of file SparseBitVect.h.

## Constructor & Destructor Documentation

SparseBitVect::SparseBitVect | ( |  | ) |
| inline

Definition at line 35 of file SparseBitVect.h.

Referenced by SparseBitVect().

SparseBitVect::SparseBitVect | ( | unsigned int | size | ) |
| inlineexplicit

initialize with a particular size;

Definition at line 37 of file SparseBitVect.h.

SparseBitVect::SparseBitVect | ( | const SparseBitVect & | other | ) |
| inline

copy constructor

Definition at line 42 of file SparseBitVect.h.

References dp_bits, getNumBits(), operator=(), and SparseBitVect().

SparseBitVect::SparseBitVect | ( | const std::string & |  | ) |

construct from a string pickle

SparseBitVect::SparseBitVect | ( | const char * | data,
|  | const unsigned int | dataLen
| ) |  |

construct from a text pickle

SparseBitVect::~SparseBitVect | ( |  | ) |
| inline

Definition at line 55 of file SparseBitVect.h.

References dp_bits, operator&(), operator[](), operator^(), operator|(), and operator~().

## Member Function Documentation

void SparseBitVect::clearBits | ( |  | ) |
| inlinevirtual

clears (sets to off) all of our bits

Implements BitVect.

Definition at line 80 of file SparseBitVect.h.

bool SparseBitVect::getBit | ( | const unsigned int | which | ) | const
| virtual

returns the value of a particular bit

Implements BitVect.

Referenced by getNumBits().

bool SparseBitVect::getBit | ( | const IntVectIter | which | ) | const

bool SparseBitVect::getBit | ( | const IntSetIter | which | ) | const

const IntSet* SparseBitVect::getBitSet | ( |  | ) | const
| inline

returns a (const) pointer to our raw storage

Definition at line 64 of file SparseBitVect.h.

References dp_bits.

unsigned int SparseBitVect::getNumBits | ( |  | ) | const
| inlinevirtual

returns the number of bits (the length of the BitVect)

Implements BitVect.

Definition at line 66 of file SparseBitVect.h.

References getBit(), setBit(), and unsetBit().

Referenced by SparseBitVect().

unsigned int SparseBitVect::getNumOffBits | ( |  | ) | const
| inlinevirtual

returns the number of off bits

Implements BitVect.

Definition at line 75 of file SparseBitVect.h.

References dp_bits, getOnBits(), and toString().

unsigned int SparseBitVect::getNumOnBits | ( |  | ) | const
| inlinevirtual

returns the number of on bits

Implements BitVect.

Definition at line 74 of file SparseBitVect.h.

References dp_bits.

void SparseBitVect::getOnBits | ( | IntVect & | v | ) | const
| virtual

replaces the contents of `v` with indices of our on bits

Implements BitVect.

Referenced by getNumOffBits().

bool SparseBitVect::operator!= | ( | const SparseBitVect & | o | ) | const
| inline

Definition at line 86 of file SparseBitVect.h.

References dp_bits, and BitVect::size().

SparseBitVect SparseBitVect::operator& | ( | const SparseBitVect & |  | ) | const

Referenced by ~SparseBitVect().

SparseBitVect& SparseBitVect::operator= | ( | const SparseBitVect & |  | ) |

Referenced by SparseBitVect().

bool SparseBitVect::operator== | ( | const SparseBitVect & | o | ) | const
| inline

Definition at line 83 of file SparseBitVect.h.

References dp_bits.

bool SparseBitVect::operator[] | ( | const unsigned int | which | ) | const
| virtual

Implements BitVect.

Referenced by ~SparseBitVect().

SparseBitVect SparseBitVect::operator^ | ( | const SparseBitVect & |  | ) | const

Referenced by ~SparseBitVect().

SparseBitVect SparseBitVect::operator| | ( | const SparseBitVect & |  | ) | const

Referenced by ~SparseBitVect().

SparseBitVect SparseBitVect::operator~ | ( |  | ) | const

Referenced by ~SparseBitVect().

bool SparseBitVect::setBit | ( | const unsigned int | which | ) |
| virtual

sets a particular bit and returns its original value

Implements BitVect.

Referenced by getNumBits().

bool SparseBitVect::setBit | ( | const IntSetIter | which | ) |

std::string SparseBitVect::toString | ( |  | ) | const
| virtual

returns a serialized (pickled) version of this BitVect

Implements BitVect.

Referenced by getNumOffBits().

bool SparseBitVect::unsetBit | ( | const unsigned int | which | ) |
| virtual

unsets a particular bit and returns its original value

Implements BitVect.

Referenced by getNumBits().

## Member Data Documentation

IntSet* SparseBitVect::dp_bits

our raw data, exposed for the sake of efficiency

Definition at line 80 of file SparseBitVect.h.

Referenced by getBitSet(), getNumOffBits(), getNumOnBits(), operator!=(), operator==(), SparseBitVect(), and ~SparseBitVect().

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

- SparseBitVect.h