Regina Calculation Engine
|
An optimised class for bitwise analysis and manipulation of native data types. More...
#include <utilities/bitmanip.h>
Public Types | |
enum | { specialised = 0 } |
Static Public Member Functions | |
static int | bits (T x) |
Returns the number of bits that are set in the given integer. More... | |
static int | firstBit (T x) |
Returns the index of the first true bit in the given integer, or -1 if the given integer is zero. More... | |
static int | lastBit (T x) |
Returns the index of the last true bit in the given integer, or -1 if the given integer is zero. More... | |
An optimised class for bitwise analysis and manipulation of native data types.
The class BitManipulator<T, size> is used to manipulate the lowest size bytes of type T, which must be an unsigned native integer type such as unsigned char, unsigned int, or unsigned long long.
The generic implementation of BitManipulator is here for completeness. All or most native types T have template specialisations that are carefully optimised (precisely what gets specialised depends upon properties of the compiler).
Like this class, all specialisations either inherit or override the default implementations from the base class GenericBitManipulator.
|
inlinestatic |
Returns the number of bits that are set in the given integer.
Specifically, this routine returns the number of bits set to 1 from amongst the lowest size bytes of x.
x | the integer of type T to examine. |
|
inlinestaticinherited |
Returns the index of the first true
bit in the given integer, or -1 if the given integer is zero.
Bits are indexed from 0 upwards, starting at the least significant bit.
x | the integer of type T to examine. |
true
bit, or -1 if there are no true
bits.
|
inlinestaticinherited |
Returns the index of the last true
bit in the given integer, or -1 if the given integer is zero.
Bits are indexed from 0 upwards, starting at the least significant bit.
x | the integer of type T to examine. |
true
bit, or -1 if there are no true
bits.