DGtal
0.6.devel
|
#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 int | nbSetBits (T val) |
static unsigned int | nbSetBits (DGtal::uint8_t val) |
static unsigned int | nbSetBits (DGtal::uint16_t val) |
static unsigned int | nbSetBits (DGtal::uint32_t val) |
static unsigned int | nbSetBits (DGtal::uint64_t val) |
static unsigned int | indexInSetBits (DGtal::uint8_t n, unsigned int b) |
static unsigned int | indexInSetBits (DGtal::uint16_t n, unsigned int b) |
static unsigned int | indexInSetBits (DGtal::uint32_t n, unsigned int b) |
static unsigned int | indexInSetBits (DGtal::uint64_t n, unsigned int b) |
static unsigned int | leastSignificantBit (DGtal::uint8_t n) |
static unsigned int | leastSignificantBit (DGtal::uint16_t n) |
static unsigned int | leastSignificantBit (DGtal::uint32_t n) |
static unsigned int | leastSignificantBit (DGtal::uint64_t n) |
Static Public Attributes | |
static const DGtal::uint8_t | myBitCount [256] |
static const DGtal::uint8_t | myLSB [256] |
static const DGtal::uint8_t | myIndexInSetBits [8][256] |
|
inlinestatic |
Bits Structs grouping all the functions of this tiny library for bitwise calculation.
Returns a string containing value's bits. Mainly designed for debugging purposes.
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. |
Definition at line 59 of file Bits.h.
Referenced by DGtal::ImageContainerByHashTree< TDomain, TValue, THashKey >::checkIntegrity(), DGtal::ImageContainerByHashTree< TDomain, TValue, THashKey >::printInternalState(), DGtal::ImageContainerByHashTree< TDomain, TValue, THashKey >::printState(), and DGtal::ImageContainerByHashTree< TDomain, TValue, THashKey >::printTree().
|
inlinestatic |
Returns a value such that only its bit corresponding to the first (least important) set bit of val, is set.
Definition at line 111 of file Bits.h.
Referenced by DGtal::Labels< L, TWord >::getLabels(), and DGtal::Labels< L, TWord >::ConstEnumerator::operator++().
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Specialization for uint8_t.
Set bits are numbered from 1 to x when reading the word from the least significant to the most significant bit. This number is the index of bit b in the number n.
b | a bit index in 0..7 |
n | a number in 0..255 |
Definition at line 209 of file Bits.h.
References myIndexInSetBits.
Referenced by DGtal::Labels< L, TWord >::index(), and indexInSetBits().
|
inlinestatic |
Specialization for uint16_t.
Set bits are numbered from 1 to x when reading the word from the least significant to the most significant bit. This number is the index of bit b in the number n.
b | a bit index in 0..15 |
n | a number in 0..65535 |
Definition at line 227 of file Bits.h.
References indexInSetBits(), and nbSetBits().
|
inlinestatic |
Specialization for uint32_t.
Set bits are numbered from 1 to x when reading the word from the least significant to the most significant bit. This number is the index of bit b in the number n.
b | a bit index in 0..31 |
n | a number in 0..2^32-1 |
Definition at line 253 of file Bits.h.
References indexInSetBits(), and nbSetBits().
|
inlinestatic |
Specialization for uint64_t.
Set bits are numbered from 1 to x when reading the word from the least significant to the most significant bit. This number is the index of bit b in the number n.
b | a bit index in 0..63 |
n | a number in 0..2^64-1 |
Definition at line 279 of file Bits.h.
References indexInSetBits(), and nbSetBits().
|
inlinestatic |
n | any number |
Definition at line 298 of file Bits.h.
References myLSB.
Referenced by DGtal::Labels< L, TWord >::getLabels(), leastSignificantBit(), and DGtal::Labels< L, TWord >::ConstEnumerator::operator++().
|
inlinestatic |
n | any number |
Definition at line 308 of file Bits.h.
References leastSignificantBit().
|
inlinestatic |
n | any number |
Definition at line 320 of file Bits.h.
References leastSignificantBit().
|
inlinestatic |
n | any number |
Definition at line 332 of file Bits.h.
References leastSignificantBit().
|
inlinestatic |
Returns an value which bits are of the form 0..010..0 with the nthBit equal to 1.
Definition at line 91 of file Bits.h.
Referenced by DGtal::ImageContainerByHashTree< TDomain, TValue, THashKey >::getCoordinatesFromKey().
|
inlinestatic |
Returns the amount of set bits in val.
Definition at line 132 of file Bits.h.
Referenced by DGtal::Labels< L, TWord >::count(), DGtal::Labels< L, TWord >::index(), indexInSetBits(), and nbSetBits().
|
inlinestatic |
Overloading for type uint8_t Returns the amount of set bits in val.
Definition at line 147 of file Bits.h.
References myBitCount.
|
inlinestatic |
Overloading for type uint16_t Returns the amount of set bits in val.
Definition at line 160 of file Bits.h.
References nbSetBits().
|
inlinestatic |
Overloading for type uint32_t Returns the amount of set bits in val.
Definition at line 174 of file Bits.h.
References nbSetBits().
|
inlinestatic |
Overloading for type uint64_t Returns the amount of set bits in val.
Definition at line 188 of file Bits.h.
References nbSetBits().
|
static |
Lookup table for counting the number of bits set to 1 in a byte. ( Taken from STL <bitset> )
Definition at line 344 of file Bits.h.
Referenced by nbSetBits().
|
static |
Usage: myIndexInSetBits[ b ][ n ]
Definition at line 360 of file Bits.h.
Referenced by indexInSetBits().
|
static |
Lookup table for finding the least significant bit.
Lookup table for finding the least significant bit.
NB: Can also be obtained with:
Definition at line 349 of file Bits.h.
Referenced by leastSignificantBit().