OpenMD  2.5
Molecular Dynamics in the Open
OpenMD::OpenMDBitSet Class Reference

OpenMDBitSet is a wrapper class of std::vector<bool> to act as a growable std::bitset. More...

#include "OpenMDBitSet.hpp"

Public Member Functions

 OpenMDBitSet ()
 
 OpenMDBitSet (int nbits)
 
int countBits ()
 
void flip (int bitIndex)
 
void flip (int fromIndex, int toIndex)
 
void flip ()
 
bool get (int bitIndex)
 
OpenMDBitSet get (int fromIndex, int toIndex)
 
bool any ()
 
bool none ()
 
int firstOffBit () const
 
int nextOffBit (int fromIndex) const
 
int firstOnBit () const
 
int nextOnBit (int fromIndex) const
 
void andOperator (const OpenMDBitSet &bs)
 
void orOperator (const OpenMDBitSet &bs)
 
void xorOperator (const OpenMDBitSet &bs)
 
void setBitOn (int bitIndex)
 
void setBitOff (int bitIndex)
 
void setRangeOn (int fromIndex, int toIndex)
 
void setRangeOff (int fromIndex, int toIndex)
 
void clearAll ()
 
void setAll ()
 
int size () const
 
void resize (int nbits)
 
OpenMDBitSetoperator &= (const OpenMDBitSet &bs)
 
OpenMDBitSetoperator|= (const OpenMDBitSet &bs)
 
OpenMDBitSetoperator^= (const OpenMDBitSet &bs)
 
OpenMDBitSetoperator-= (const OpenMDBitSet &bs)
 
OpenMDBitSet parallelReduce ()
 
bool operator[] (int bitIndex) const
 

Private Member Functions

void setBit (int bitIndex, bool value)
 
void setBits (int fromIndex, int toIndex, bool value)
 

Private Attributes

std::vector< bool > bitset_
 

Friends

OpenMDBitSet operator| (const OpenMDBitSet &bs1, const OpenMDBitSet &bs2)
 
OpenMDBitSet operator & (const OpenMDBitSet &bs1, const OpenMDBitSet &bs2)
 
OpenMDBitSet operator^ (const OpenMDBitSet &bs1, const OpenMDBitSet &bs2)
 
OpenMDBitSet operator- (const OpenMDBitSet &bs1, const OpenMDBitSet &bs2)
 
bool operator== (const OpenMDBitSet &bs1, const OpenMDBitSet &bs2)
 
std::ostream & operator<< (std::ostream &, const OpenMDBitSet &bs)
 

Detailed Description

OpenMDBitSet is a wrapper class of std::vector<bool> to act as a growable std::bitset.

Definition at line 54 of file OpenMDBitSet.hpp.

Constructor & Destructor Documentation

◆ OpenMDBitSet() [1/2]

OpenMD::OpenMDBitSet::OpenMDBitSet ( )
inline

Definition at line 57 of file OpenMDBitSet.hpp.

◆ OpenMDBitSet() [2/2]

OpenMD::OpenMDBitSet::OpenMDBitSet ( int  nbits)
inline

Definition at line 59 of file OpenMDBitSet.hpp.

References clearAll(), and countBits().

Member Function Documentation

◆ andOperator()

void OpenMD::OpenMDBitSet::andOperator ( const OpenMDBitSet bs)

Performs a logical AND of this target bit set with the argument bit set.

Definition at line 130 of file OpenMDBitSet.cpp.

References bitset_, and size().

Referenced by firstOnBit(), and operator &=().

◆ any()

bool OpenMD::OpenMDBitSet::any ( )
inline

Returns true if any bits are set to true

Definition at line 80 of file OpenMDBitSet.hpp.

References none().

◆ clearAll()

void OpenMD::OpenMDBitSet::clearAll ( )
inline

Sets all of the bits in this OpenMDBitSet to false.

Definition at line 113 of file OpenMDBitSet.hpp.

References setRangeOff(), and size().

Referenced by OpenMDBitSet().

◆ countBits()

int OpenMD::OpenMDBitSet::countBits ( )

Returns the number of bits set to true in this OpenMDBitSet.

Definition at line 56 of file OpenMDBitSet.cpp.

References bitset_.

Referenced by OpenMDBitSet().

◆ firstOffBit()

int OpenMD::OpenMDBitSet::firstOffBit ( ) const
inline

Definition at line 85 of file OpenMDBitSet.hpp.

References bitset_, and nextOffBit().

◆ firstOnBit()

int OpenMD::OpenMDBitSet::firstOnBit ( ) const
inline

Definition at line 90 of file OpenMDBitSet.hpp.

References andOperator(), bitset_, nextOnBit(), orOperator(), and xorOperator().

◆ flip() [1/3]

void OpenMD::OpenMDBitSet::flip ( int  bitIndex)
inline

Sets the bit at the specified index to to the complement of its current value.

Definition at line 65 of file OpenMDBitSet.hpp.

References bitset_, and flip().

◆ flip() [2/3]

void OpenMD::OpenMDBitSet::flip ( int  fromIndex,
int  toIndex 
)

Sets each bit from the specified fromIndex(inclusive) to the specified toIndex(exclusive) to the complement of its current value.

Definition at line 68 of file OpenMDBitSet.cpp.

References bitset_, OpenMD::first, and size().

◆ flip() [3/3]

void OpenMD::OpenMDBitSet::flip ( )
inline

Sets each bit to the complement of its current value.

Definition at line 71 of file OpenMDBitSet.hpp.

References flip(), and size().

Referenced by flip().

◆ get() [1/2]

bool OpenMD::OpenMDBitSet::get ( int  bitIndex)
inline

Returns the value of the bit with the specified index.

Definition at line 74 of file OpenMDBitSet.hpp.

References bitset_.

◆ get() [2/2]

OpenMDBitSet OpenMD::OpenMDBitSet::get ( int  fromIndex,
int  toIndex 
)

Returns a new OpenMDBitSet composed of bits from this OpenMDBitSet from fromIndex(inclusive) to toIndex(exclusive).

Definition at line 79 of file OpenMDBitSet.cpp.

References bitset_, OpenMD::first, and size().

◆ nextOffBit()

int OpenMD::OpenMDBitSet::nextOffBit ( int  fromIndex) const

Returns the index of the first bit that is set to false that occurs on or after the specified starting index.

Definition at line 96 of file OpenMDBitSet.cpp.

References bitset_, and size().

Referenced by firstOffBit().

◆ nextOnBit()

int OpenMD::OpenMDBitSet::nextOnBit ( int  fromIndex) const

Returns the index of the first bit that is set to true that occurs on or after the specified starting index.

Definition at line 113 of file OpenMDBitSet.cpp.

References bitset_, and size().

Referenced by firstOnBit().

◆ none()

bool OpenMD::OpenMDBitSet::none ( )

Returns true if no bits are set to true

Definition at line 91 of file OpenMDBitSet.cpp.

References bitset_.

Referenced by any().

◆ operator &=()

OpenMDBitSet& OpenMD::OpenMDBitSet::operator&= ( const OpenMDBitSet bs)
inline

Definition at line 123 of file OpenMDBitSet.hpp.

References andOperator().

◆ operator-=()

OpenMDBitSet& OpenMD::OpenMDBitSet::operator-= ( const OpenMDBitSet bs)
inline

Definition at line 126 of file OpenMDBitSet.hpp.

References parallelReduce().

◆ operator[]()

bool OpenMD::OpenMDBitSet::operator[] ( int  bitIndex) const
inline

Definition at line 134 of file OpenMDBitSet.hpp.

References bitset_, operator &, operator-, operator<<, operator==, operator^, and operator|.

◆ operator^=()

OpenMDBitSet& OpenMD::OpenMDBitSet::operator^= ( const OpenMDBitSet bs)
inline

Definition at line 125 of file OpenMDBitSet.hpp.

References xorOperator().

◆ operator|=()

OpenMDBitSet& OpenMD::OpenMDBitSet::operator|= ( const OpenMDBitSet bs)
inline

Definition at line 124 of file OpenMDBitSet.hpp.

References orOperator().

◆ orOperator()

void OpenMD::OpenMDBitSet::orOperator ( const OpenMDBitSet bs)

Performs a logical OR of this bit set with the bit set argument.

Definition at line 136 of file OpenMDBitSet.cpp.

References bitset_, and size().

Referenced by firstOnBit(), and operator|=().

◆ parallelReduce()

OpenMDBitSet OpenMD::OpenMDBitSet::parallelReduce ( )

Definition at line 200 of file OpenMDBitSet.cpp.

References bitset_.

Referenced by operator-=().

◆ resize()

void OpenMD::OpenMDBitSet::resize ( int  nbits)

Changes the size of OpenMDBitSet

Definition at line 155 of file OpenMDBitSet.cpp.

References bitset_, and size().

Referenced by size().

◆ setAll()

void OpenMD::OpenMDBitSet::setAll ( )
inline

Definition at line 115 of file OpenMDBitSet.hpp.

References setRangeOn(), and size().

◆ setBit()

void OpenMD::OpenMDBitSet::setBit ( int  bitIndex,
bool  value 
)
inlineprivate

Sets the bit at the specified index to the specified value.

Definition at line 148 of file OpenMDBitSet.hpp.

References bitset_, and setBits().

Referenced by setBitOff(), and setBitOn().

◆ setBitOff()

void OpenMD::OpenMDBitSet::setBitOff ( int  bitIndex)
inline

Definition at line 106 of file OpenMDBitSet.hpp.

References setBit().

◆ setBitOn()

void OpenMD::OpenMDBitSet::setBitOn ( int  bitIndex)
inline

Definition at line 104 of file OpenMDBitSet.hpp.

References setBit().

◆ setBits()

void OpenMD::OpenMDBitSet::setBits ( int  fromIndex,
int  toIndex,
bool  value 
)
private

Sets the bits from the specified fromIndex(inclusive) to the specified toIndex(exclusive) to the specified value.

Definition at line 146 of file OpenMDBitSet.cpp.

References bitset_, OpenMD::first, and size().

Referenced by setBit(), setRangeOff(), and setRangeOn().

◆ setRangeOff()

void OpenMD::OpenMDBitSet::setRangeOff ( int  fromIndex,
int  toIndex 
)
inline

Definition at line 110 of file OpenMDBitSet.hpp.

References setBits().

Referenced by clearAll().

◆ setRangeOn()

void OpenMD::OpenMDBitSet::setRangeOn ( int  fromIndex,
int  toIndex 
)
inline

Definition at line 108 of file OpenMDBitSet.hpp.

References setBits().

Referenced by setAll().

◆ size()

int OpenMD::OpenMDBitSet::size ( ) const
inline

Returns the number of bits of space actually in use by this OpenMDBitSet to represent bit values.

Definition at line 118 of file OpenMDBitSet.hpp.

References bitset_, and resize().

Referenced by andOperator(), clearAll(), flip(), get(), nextOffBit(), nextOnBit(), OpenMD::operator &(), OpenMD::operator-(), OpenMD::operator==(), OpenMD::operator^(), OpenMD::operator|(), orOperator(), resize(), setAll(), setBits(), and xorOperator().

◆ xorOperator()

void OpenMD::OpenMDBitSet::xorOperator ( const OpenMDBitSet bs)

Performs a logical XOR of this bit set with the bit set argument.

Definition at line 141 of file OpenMDBitSet.cpp.

References bitset_, and size().

Referenced by firstOnBit(), and operator^=().

Friends And Related Function Documentation

◆ operator &

OpenMDBitSet operator& ( const OpenMDBitSet bs1,
const OpenMDBitSet bs2 
)
friend

Definition at line 171 of file OpenMDBitSet.cpp.

Referenced by operator[]().

◆ operator-

OpenMDBitSet operator- ( const OpenMDBitSet bs1,
const OpenMDBitSet bs2 
)
friend

Definition at line 187 of file OpenMDBitSet.cpp.

Referenced by operator[]().

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const OpenMDBitSet bs 
)
friend

Definition at line 233 of file OpenMDBitSet.cpp.

Referenced by operator[]().

◆ operator==

bool operator== ( const OpenMDBitSet bs1,
const OpenMDBitSet bs2 
)
friend

Definition at line 195 of file OpenMDBitSet.cpp.

Referenced by operator[]().

◆ operator^

OpenMDBitSet operator^ ( const OpenMDBitSet bs1,
const OpenMDBitSet bs2 
)
friend

Definition at line 179 of file OpenMDBitSet.cpp.

Referenced by operator[]().

◆ operator|

OpenMDBitSet operator| ( const OpenMDBitSet bs1,
const OpenMDBitSet bs2 
)
friend

Definition at line 163 of file OpenMDBitSet.cpp.

Referenced by operator[]().

Member Data Documentation

◆ bitset_


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