bitfield_c< bits > Class Template Reference

this is a fast class to have a bit vector with a constant number of bits the number it dependend on the template parameter More...

#include <bitfield.h>

List of all members.

Public Member Functions

 bitfield_c ()
 constructor, all bits are cleared at the beginning
 bitfield_c (const char *val)
 constructor, the bits are initialized to the value of the string
 bitfield_c (const bitfield_c< bits > &orig)
 copy constructor
bool get (uint16_t pos) const
 get a bit
void set (uint16_t pos)
 set a bit to one
void reset (uint16_t pos)
 set a bit to zero
void clear (void)
 set all bits to zero
bool notNull (void)
 check, if at least one bit is set to 1
const bitfield_c< bits > & operator= (const char *val)
 assign the the string repesentation of a value to the bits of this bitfield
bool operator== (const bitfield_c< bits > &op) const
 comparison of 2 bitfields
bool operator!= (const bitfield_c< bits > &op) const
 inequality test of 2 bitfields
unsigned int countbits (void) const
 find the number of set bits in the bitfield
void print (char *str, unsigned int len) const
 put the value of the bitfield into the string str.
void print (void) const
 use printf to display the content of the string
const bitfield_c< bits > operator& (const bitfield_c< bits > &right) const
 bitwise and of 2 bitfields
const bitfield_c< bits > operator| (const bitfield_c< bits > &right) const
 bitwise or of 2 bitfields

Private Attributes

uint64_t field [(bits+63)/64]
 the bitfield


Detailed Description

template<int bits>
class bitfield_c< bits >

this is a fast class to have a bit vector with a constant number of bits the number it dependend on the template parameter

Constructor & Destructor Documentation

template<int bits>
bitfield_c< bits >::bitfield_c (  )  [inline]

constructor, all bits are cleared at the beginning

References bitfield_c< bits >::clear().

template<int bits>
bitfield_c< bits >::bitfield_c ( const char *  val  )  [inline]

constructor, the bits are initialized to the value of the string

References bitfield_c< bits >::clear(), and bitfield_c< bits >::operator=().

template<int bits>
bitfield_c< bits >::bitfield_c ( const bitfield_c< bits > &  orig  )  [inline]

copy constructor

References bitfield_c< bits >::field.


Member Function Documentation

template<int bits>
void bitfield_c< bits >::clear ( void   )  [inline]

template<int bits>
unsigned int bitfield_c< bits >::countbits ( void   )  const [inline]

find the number of set bits in the bitfield

The method add up the number of set bits in each 64 bit entry of the bitvector. This value is calculated using a method similar to this: http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel

References bitfield_c< bits >::field.

Referenced by symmetries_2_c::countSymmetryIntersection().

template<int bits>
bool bitfield_c< bits >::get ( uint16_t  pos  )  const [inline]

template<int bits>
bool bitfield_c< bits >::notNull ( void   )  [inline]

template<int bits>
bool bitfield_c< bits >::operator!= ( const bitfield_c< bits > &  op  )  const [inline]

inequality test of 2 bitfields

References bitfield_c< bits >::field.

template<int bits>
const bitfield_c<bits> bitfield_c< bits >::operator& ( const bitfield_c< bits > &  right  )  const [inline]

bitwise and of 2 bitfields

References bitfield_c< bits >::field.

template<int bits>
const bitfield_c<bits>& bitfield_c< bits >::operator= ( const char *  val  )  [inline]

assign the the string repesentation of a value to the bits of this bitfield

The string must be a hexadecimal value, no prefix no suffix, you can use upper and lower case letters.

The string must not be larget than allowed. If the string is shorter than necessary the remaining values are left untouched, so it's up to you to clear them before calling this function

References bt_assert, and bitfield_c< bits >::field.

Referenced by bitfield_c< bits >::bitfield_c().

template<int bits>
bool bitfield_c< bits >::operator== ( const bitfield_c< bits > &  op  )  const [inline]

comparison of 2 bitfields

References bitfield_c< bits >::field.

template<int bits>
const bitfield_c<bits> bitfield_c< bits >::operator| ( const bitfield_c< bits > &  right  )  const [inline]

bitwise or of 2 bitfields

References bitfield_c< bits >::field.

template<int bits>
void bitfield_c< bits >::print ( void   )  const [inline]

use printf to display the content of the string

References bitfield_c< bits >::field.

template<int bits>
void bitfield_c< bits >::print ( char *  str,
unsigned int  len 
) const [inline]

put the value of the bitfield into the string str.

not more than len characters are written

References bitfield_c< bits >::field.

template<int bits>
void bitfield_c< bits >::reset ( uint16_t  pos  )  [inline]

template<int bits>
void bitfield_c< bits >::set ( uint16_t  pos  )  [inline]

set a bit to one

References bt_assert, and bitfield_c< bits >::field.

Referenced by BOOST_AUTO_TEST_CASE(), and symmetries_2_c::symmetryKnown().


Member Data Documentation

template<int bits>
uint64_t bitfield_c< bits >::field[(bits+63)/64] [private]


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

Generated on Sun Oct 10 10:02:44 2010 for BurrTools by  doxygen 1.5.8