Bits Struct Reference

Bits Struct grouping all the functions of this tiny library for bitwise calculation. More...

#include <Bits.h>

Data Structures

class  LOG2
class  LOG2< 1 >
class  LOG2< 2 >
class  POW
class  POW< X, 1 >

Public Member 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

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


Member 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().

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().

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

Returns the amount of set bits in val.


The documentation for this struct was generated from the following file:
Generated on Wed Sep 29 15:45:58 2010 for DGtal by  doxygen 1.6.3