Phoenix
Object-oriented orthogonally persistent operating system
Public Member Functions
BitString< numBits > Class Template Reference

Class for manipulating bit strings. More...

#include <BitString.h>

List of all members.

Public Member Functions

void Set (size_t idx)
 Set bit at specified position.
void Clear (size_t idx)
 Clear bit at specified position.
bool IsSet (size_t idx)
 Check if bit is set at specified position.
bool IsClear (size_t idx)
 Check if bit is clear at specified position.
bool operator[] (size_t idx)
 Check if bit is set at specified position.
int FirstSet ()
 Find first set bit.
int FirstClear ()
 Find first clear bit.
void ClearAll ()
 Clear all bits in the string.

Detailed Description

template<size_t numBits = 0>
class BitString< numBits >

Class for manipulating bit strings.

Bit string is a sequence of bits which are indexed by a null-based index. Each bit in a string can be accessed (checked or modified) individually by its index.

Parameters:
numBitsNumber of bits in a string. If this parameter is not zero then the string is allocated statically in the class. Otherwise the string is allocated by the caller and the bitmap and number of bits are provided to the constructor.

Member Function Documentation

template<size_t numBits = 0>
void BitString< numBits >::Clear ( size_t  idx) [inline]

Clear bit at specified position.

Parameters:
idxNull based bit index.
template<size_t numBits = 0>
void BitString< numBits >::ClearAll ( ) [inline]

Clear all bits in the string.

template<size_t numBits = 0>
int BitString< numBits >::FirstClear ( ) [inline]

Find first clear bit.

Returns:
Index of first bit set. -1 if no bits set.
template<size_t numBits = 0>
int BitString< numBits >::FirstSet ( ) [inline]

Find first set bit.

Returns:
Index of first bit set. -1 if no bits set.
template<size_t numBits = 0>
bool BitString< numBits >::IsClear ( size_t  idx) [inline]

Check if bit is clear at specified position.

Parameters:
idxNull based bit index.
Returns:
true if the bit is clear, false otherwise.
template<size_t numBits = 0>
bool BitString< numBits >::IsSet ( size_t  idx) [inline]

Check if bit is set at specified position.

Parameters:
idxNull based bit index.
Returns:
true if the bit is set, false otherwise.
template<size_t numBits = 0>
bool BitString< numBits >::operator[] ( size_t  idx) [inline]

Check if bit is set at specified position.

Equivalent of IsSet method.

Parameters:
idxNull based bit index.
Returns:
true if the bit is set, false otherwise.
template<size_t numBits = 0>
void BitString< numBits >::Set ( size_t  idx) [inline]

Set bit at specified position.

Parameters:
idxNull based bit index.

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines