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 () override
bool | operator[] (const unsigned int which) const override
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 override
| returns the number of bits (the length of the BitVect) More...
bool | setBit (const unsigned int which) override
| sets a particular bit and returns its original value More...
bool | setBit (const IntSetIter which)
bool | unsetBit (const unsigned int which) override
| unsets a particular bit and returns its original value More...
bool | getBit (const unsigned int which) const override
| returns the value of a particular bit More...
bool | getBit (const IntVectIter which) const
bool | getBit (const IntSetIter which) const
unsigned int | getNumOnBits () const override
| returns the number of on bits More...
unsigned int | getNumOffBits () const override
| returns the number of off bits More...
std::string | toString () const override
| returns a serialized (pickled) version of this BitVect More...
void | getOnBits (IntVect &v) const override
| replaces the contents of `v` with indices of our on bits More...
void | clearBits () override
| 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 34 of file SparseBitVect.h.

## Constructor & Destructor Documentation

## SparseBitVect() [1/5]

SparseBitVect::SparseBitVect | ( |  | ) |

inline

Definition at line 36 of file SparseBitVect.h.

## SparseBitVect() [2/5]

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

inline explicit

initialize with a particular size;

Definition at line 38 of file SparseBitVect.h.

## SparseBitVect() [3/5]

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

inline

copy constructor

Definition at line 43 of file SparseBitVect.h.

References dp_bits, and getNumBits().

## SparseBitVect() [4/5]

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

construct from a string pickle

## SparseBitVect() [5/5]

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

construct from a text pickle

## ~SparseBitVect()

SparseBitVect::~SparseBitVect | ( |  | ) |

inline override

Definition at line 56 of file SparseBitVect.h.

## Member Function Documentation

## clearBits()

void SparseBitVect::clearBits | ( |  | ) |

inline override virtual

clears (sets to off) all of our bits

Implements BitVect.

Definition at line 85 of file SparseBitVect.h.

## getBit() [1/3]

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

## getBit() [2/3]

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

## getBit() [3/3]

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

override virtual

returns the value of a particular bit

Implements BitVect.

## getBitSet()

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

inline

returns a (const) pointer to our raw storage

Definition at line 65 of file SparseBitVect.h.

## getNumBits()

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

inline override virtual

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

Implements BitVect.

Definition at line 67 of file SparseBitVect.h.

Referenced by SparseBitVect().

## getNumOffBits()

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

inline override virtual

returns the number of off bits

Implements BitVect.

Definition at line 78 of file SparseBitVect.h.

## getNumOnBits()

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

inline override virtual

returns the number of on bits

Implements BitVect.

Definition at line 75 of file SparseBitVect.h.

## getOnBits()

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

override virtual

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

Implements BitVect.

## operator!=()

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

inline

Definition at line 92 of file SparseBitVect.h.

References dp_bits.

## operator&()

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

## operator=()

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

## operator==()

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

inline

Definition at line 89 of file SparseBitVect.h.

References dp_bits.

## operator[]()

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

override virtual

Implements BitVect.

## operator^()

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

## operator|()

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

## operator~()

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

## setBit() [1/2]

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

## setBit() [2/2]

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

override virtual

sets a particular bit and returns its original value

Implements BitVect.

## toString()

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

override virtual

returns a serialized (pickled) version of this BitVect

Implements BitVect.

## unsetBit()

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

override virtual

unsets a particular bit and returns its original value

Implements BitVect.

## Member Data Documentation

## dp_bits

IntSet* SparseBitVect::dp_bits

Initial value:
{
nullptr}

our raw data, exposed for the sake of efficiency

Definition at line 86 of file SparseBitVect.h.

Referenced by operator!=(), operator==(), and SparseBitVect().

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

- SparseBitVect.h