Nemo  2.4.2
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
bitstring::reference Class Reference

#include <bitstring.h>

+ Collaboration diagram for bitstring::reference:

Public Member Functions

 reference (bitstring &bs, size_t pos)
 
 ~reference ()
 
referenceoperator= (bool x)
 
referenceoperator= (const reference &j)
 
bool operator~ () const
 
 operator bool () const
 
referenceflip ()
 

Private Member Functions

 reference ()
 

Private Attributes

_ul_word
 
size_t _bitpos
 

Friends

class bitstring
 

Constructor & Destructor Documentation

◆ reference() [1/2]

bitstring::reference::reference ( )
private

◆ reference() [2/2]

bitstring::reference::reference ( bitstring bs,
size_t  pos 
)
inline
71  {
72  _word = bs.getword_atPos( pos );
73  _bitpos = pos % BITS_PER_WORD;
74  }
#define BITS_PER_WORD
Definition: bitstring.h:39
_ul * _word
Definition: bitstring.h:63
size_t _bitpos
Definition: bitstring.h:64
_ul * getword_atPos(size_t pos) const
Definition: bitstring.h:152

References _bitpos, _word, BITS_PER_WORD, and bitstring::getword_atPos().

◆ ~reference()

bitstring::reference::~reference ( )
inline
77  { }

Member Function Documentation

◆ flip()

reference& bitstring::reference::flip ( )
inline
109  {
110  *_word ^= ( 1UL << ( _bitpos % BITS_PER_WORD ) );
111  return *this;
112  }

References _bitpos, _word, and BITS_PER_WORD.

◆ operator bool()

bitstring::reference::operator bool ( ) const
inline
105  { return (*(_word) & ( 1UL << ( _bitpos % BITS_PER_WORD ) ) ) != 0; }

References _bitpos, _word, and BITS_PER_WORD.

◆ operator=() [1/2]

reference& bitstring::reference::operator= ( bool  x)
inline
81  {
82  if (x)
83  *_word |= ( 1UL << ( _bitpos % BITS_PER_WORD ) );
84  else
85  *_word &= ~( 1UL << ( _bitpos % BITS_PER_WORD ) );
86  return *this;
87  }

References _bitpos, _word, and BITS_PER_WORD.

◆ operator=() [2/2]

reference& bitstring::reference::operator= ( const reference j)
inline
91  {
92  if ((*(j._word) & ( 1UL << ( j._bitpos % BITS_PER_WORD ) ) ))
93  *_word |= ( 1UL << ( _bitpos % BITS_PER_WORD ) );
94  else
95  *_word &= ~( 1UL << ( _bitpos % BITS_PER_WORD ) );
96  return *this;
97  }

References _bitpos, _word, and BITS_PER_WORD.

◆ operator~()

bool bitstring::reference::operator~ ( ) const
inline
101  { return (*(_word) & ( 1UL << ( _bitpos % BITS_PER_WORD ) ) ) == 0; }

References _bitpos, _word, and BITS_PER_WORD.

Friends And Related Function Documentation

◆ bitstring

friend class bitstring
friend

Member Data Documentation

◆ _bitpos

size_t bitstring::reference::_bitpos
private

◆ _word

_ul* bitstring::reference::_word
private

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

Generated for Nemo v2.4.2 by  doxygen 1.9.1

Catalogued on GSR