DGtal
1.5.beta
|
#include <DGtal/base/Bits.h>
Static Public Member Functions | |
template<typename T > | |
static std::string | bitString (T value, unsigned nbBits=0) |
Bits Structs grouping all the functions of this tiny library for bitwise calculation. More... | |
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 unsigned int | mostSignificantBit (DGtal::uint8_t n) |
static unsigned int | mostSignificantBit (DGtal::uint16_t n) |
static unsigned int | mostSignificantBit (DGtal::uint32_t n) |
static unsigned int | mostSignificantBit (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 | myMSB [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 57 of file Bits.h.
Referenced by test_get(), and test_setVal().
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
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 225 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 251 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 277 of file Bits.h.
References indexInSetBits(), and nbSetBits().
|
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 207 of file Bits.h.
References myIndexInSetBits.
Referenced by indexInSetBits(), and main().
|
inlinestatic |
n | any number |
Definition at line 307 of file Bits.h.
References leastSignificantBit().
|
inlinestatic |
n | any number |
Definition at line 319 of file Bits.h.
References leastSignificantBit().
|
inlinestatic |
n | any number |
Definition at line 331 of file Bits.h.
References leastSignificantBit().
|
inlinestatic |
n | any number |
Definition at line 297 of file Bits.h.
References myLSB.
Referenced by DGtal::UnorderedSetByBlock< Key, TSplitter, Hash, KeyEqual, UnorderedMapAllocator >::const_iterator::const_iterator(), DGtal::UnorderedSetByBlock< Key, TSplitter, Hash, KeyEqual, UnorderedMapAllocator >::const_iterator::increment(), DGtal::UnorderedSetByBlock< Key, TSplitter, Hash, KeyEqual, UnorderedMapAllocator >::iterator::increment(), DGtal::UnorderedSetByBlock< Key, TSplitter, Hash, KeyEqual, UnorderedMapAllocator >::iterator::iterator(), and leastSignificantBit().
|
inlinestatic |
|
inlinestatic |
n | any number |
Definition at line 353 of file Bits.h.
References mostSignificantBit().
|
inlinestatic |
n | any number |
Definition at line 365 of file Bits.h.
References mostSignificantBit().
|
inlinestatic |
n | any number |
Definition at line 377 of file Bits.h.
References mostSignificantBit().
|
inlinestatic |
n | any number |
Definition at line 343 of file Bits.h.
References myMSB.
Referenced by mostSignificantBit(), and DGtal::functions::roundToUpperPowerOfTwo().
|
inlinestatic |
Overloading for type uint16_t Returns the amount of set bits in val.
Definition at line 158 of file Bits.h.
References nbSetBits().
|
inlinestatic |
Overloading for type uint32_t Returns the amount of set bits in val.
Definition at line 172 of file Bits.h.
References nbSetBits().
|
inlinestatic |
Overloading for type uint64_t Returns the amount of set bits in val.
Definition at line 186 of file Bits.h.
References nbSetBits().
|
inlinestatic |
Overloading for type uint8_t Returns the amount of set bits in val.
Definition at line 145 of file Bits.h.
References myBitCount.
|
inlinestatic |
Returns the amount of set bits in val.
Definition at line 130 of file Bits.h.
Referenced by DGtal::UnorderedSetByBlock< Key, TSplitter, Hash, KeyEqual, UnorderedMapAllocator >::erase(), indexInSetBits(), main(), and nbSetBits().
|
static |
Lookup table for counting the number of bits set to 1 in a byte. ( Taken from STL <bitset> )
Definition at line 390 of file Bits.h.
Referenced by nbSetBits().
|
static |
Usage: myIndexInSetBits[ b ][ n ]
Definition at line 411 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 395 of file Bits.h.
Referenced by leastSignificantBit().
|
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 400 of file Bits.h.
Referenced by mostSignificantBit().