Static Public Member Functions

DGtal::Bits Struct Reference

#include <Bits.h>

Static Public Member Functions

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

Member Function Documentation

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

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

Todo:
Check that T is CInteger.

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(), and test_setVal().

template<typename T >
static T DGtal::Bits::firstSetBit ( val  )  [inline, static]

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

template<typename T >
static T DGtal::Bits::firstUnsetBit ( val  )  [inline, static]

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

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

Returns the state of key's nthBit bit.

template<typename T >
static T DGtal::Bits::mask ( unsigned  nthBit  )  [inline, static]

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

Referenced by bitString().

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

Returns the amount of set bits in val.


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