Regina Calculation Engine
Public Types | Static Public Member Functions
regina::BitManipulator< T, size > 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, size >:
regina::GenericBitManipulator< T, size >

List of all members.

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.
- Static Public Member Functions inherited from regina::GenericBitManipulator< T, size >
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.
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.

Detailed Description

template<typename T, unsigned size = sizeof(T)>
class regina::BitManipulator< T, size >

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.

Precondition:
Type T is an unsigned integral numeric type.
The argument size is a power of two, and is at most sizeof(T).
Python:
Not present.

Member Enumeration Documentation

template<typename T , unsigned size = sizeof(T)>
anonymous enum
Enumerator:
specialised 

Indicates whether this class is a template specialisation of BitManipulator with extra optimisations.

This compile-time constant is set to 0 for the generic implementation of BitManipulator, and 1 for all specialisations.


Member Function Documentation

template<typename T , unsigned size = sizeof(T)>
static int regina::BitManipulator< T, size >::bits ( x)
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.

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-2012, The Regina development team
This software is released under the GNU General Public License.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@debian.org).