#include <bitfield.h>
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 |
bitfield_c< bits >::bitfield_c | ( | ) | [inline] |
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=().
bitfield_c< bits >::bitfield_c | ( | const bitfield_c< bits > & | orig | ) | [inline] |
void bitfield_c< bits >::clear | ( | void | ) | [inline] |
set all bits to zero
References bitfield_c< bits >::field.
Referenced by bitfield_c< bits >::bitfield_c(), BOOST_AUTO_TEST_CASE(), and symmetries_2_c::symmetryKnown().
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().
bool bitfield_c< bits >::get | ( | uint16_t | pos | ) | const [inline] |
get a bit
References bt_assert, and bitfield_c< bits >::field.
Referenced by BOOST_AUTO_TEST_CASE(), symmetries_2_c::isTransformationUnique(), and symmetries_2_c::symmetrieContainsTransformation().
bool bitfield_c< bits >::notNull | ( | void | ) | [inline] |
check, if at least one bit is set to 1
References bitfield_c< bits >::field.
Referenced by BOOST_AUTO_TEST_CASE(), symmetries_2_c::symmetriesLeft(), and symmetries_2_c::symmetryContainsMirror().
bool bitfield_c< bits >::operator!= | ( | const bitfield_c< bits > & | op | ) | const [inline] |
const bitfield_c<bits> bitfield_c< bits >::operator& | ( | const bitfield_c< bits > & | right | ) | const [inline] |
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().
bool bitfield_c< bits >::operator== | ( | const bitfield_c< bits > & | op | ) | const [inline] |
const bitfield_c<bits> bitfield_c< bits >::operator| | ( | const bitfield_c< bits > & | right | ) | const [inline] |
void bitfield_c< bits >::print | ( | void | ) | const [inline] |
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.
void bitfield_c< bits >::reset | ( | uint16_t | pos | ) | [inline] |
set a bit to zero
References bt_assert, and bitfield_c< bits >::field.
Referenced by BOOST_AUTO_TEST_CASE(), symmetries_2_c::symmetriesLeft(), and symmetries_2_c::symmetryContainsMirror().
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().
uint64_t bitfield_c< bits >::field[(bits+63)/64] [private] |
the bitfield
Referenced by bitfield_c< bits >::bitfield_c(), bitfield_c< bits >::clear(), bitfield_c< bits >::countbits(), bitfield_c< bits >::get(), bitfield_c< bits >::notNull(), bitfield_c< bits >::operator!=(), bitfield_c< bits >::operator&(), bitfield_c< bits >::operator=(), bitfield_c< bits >::operator==(), bitfield_c< bits >::operator|(), bitfield_c< bits >::print(), bitfield_c< bits >::reset(), and bitfield_c< bits >::set().