bits Namespace Reference

Data Structures

class  POW
class  POW< X, 1 >

Functions

template<typename T >
std::string bitString (T value, unsigned nbBits=0)
template<typename T >
mask (unsigned nthBit)
template<typename T >
bool getBit (T key, unsigned nthBit)
template<typename T >
firstSetBit (T val)
template<typename T >
firstUnsetBit (T val)
template<typename T >
unsigned nbSetBits (T val)

Detailed Description

Namespace grouping all the functions of this tiny library for bitwise calculation.


Function Documentation

template<typename T >
std::string bits::bitString ( value,
unsigned  nbBits = 0 
) [inline]

Returns a string containing value's bits. Mainly designed for debugging purposes.

Parameters:
value The value that you need to dipslay as a bit string.
nbBits number of bits to be displayed. If equal to 0, the number of bits will correspond to the size of the type T.

References mask(), and mymin.

Referenced by test_get(), test_setVal(), and testMorton().

template<typename T >
T bits::firstSetBit ( val  )  [inline]

Returns a value such that only its bit corresponding to the first (least important) set bit of val, is set.

template<typename T >
T bits::firstUnsetBit ( val  )  [inline]

Returns a value such that only its bit corresponding to the first (least important) unset bit of val, is set.

template<typename T >
bool bits::getBit ( key,
unsigned  nthBit 
) [inline]

Returns the state of key's nthBit bit.

template<typename T >
T bits::mask ( unsigned  nthBit  )  [inline]

Returns an value which bits are of the form 0..010..0 with the nthBit equal to 1.

Referenced by bitString(), DGtal::Morton< THashKey, TPoint >::brotherKeys(), and DGtal::Morton< THashKey, TPoint >::childrenKeys().

template<typename T >
unsigned bits::nbSetBits ( val  )  [inline]

Returns the amount of set bits in val.

Generated on Fri Sep 17 17:30:01 2010 for DGtal by  doxygen 1.6.3