Regina Calculation Engine
Public Types | Static Public Member Functions | List of all members
regina::BitManipulator< T > Class Template Reference

An optimised class for bitwise analysis and manipulation of native data types. More...

#include <utilities/bitmanip.h>

Inheritance diagram for regina::BitManipulator< T >:
regina::BitManipulatorByType< T > regina::BitManipulatorBySize< T >

Public Types

enum  { specialised }
 
enum  { specialised = 0 }
 
enum  
 

Static Public Member Functions

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...
 
static T nextPermutation (T x)
 Returns the next largest integer with the same number of true bits as x. More...
 
static int bits (T x)
 Returns the number of bits that are set to 1 in the given integer. More...
 

Detailed Description

template<typename T>
class regina::BitManipulator< T >

An optimised class for bitwise analysis and manipulation of native data types.

The class BitManipulator<T> is used to manipulate an integer of type T as a sequence of bits. Here T must be an unsigned native integer type such as unsigned char, unsigned int, or unsigned long long.

Whilst BitManipulator has a generic implementation, all or most native types T have template specialisations that are carefully optimised (precisely what gets specialised depends upon properties of the compiler).

Precondition
Type T is an unsigned integral numeric type whose size in bits is a power of two.
Python:\n Not present.

Member Function Documentation

◆ bits()

static int regina::BitManipulatorBySize< T, sizeof(T) >::bits ( x)
inlinestaticinherited

Returns the number of bits that are set to 1 in the given integer.

Parameters
xthe integer of type T to examine.
Returns
the number of bits that are set.

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

Copyright © 1999-2018, The Regina development team
This software is released under the GNU General Public License, with some additional permissions; see the source code for details.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@maths.uq.edu.au).