# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NLMISC::CBitSet Class Reference

A BitSet, to test / set flags quickly. More...

#include <bit_set.h>

List of all members.

Public Methods

void serial (NLMISC::IStream &f)
Object.
 CBitSet ()
 CBitSet (uint numBits)
 CBitSet (const CBitSet &bs)
 ~CBitSet ()
CBitSet & operator= (const CBitSet &bs)
Basics.
void resize (uint numBits)
 Resize the bit array. All Bits are reseted. More...

void resizeNoReset (uint numBits, bool value=false)
 Resize the bit array. Bits are not reseted. New bits are set with value. More...

void clear ()
 Clear the bitarray so size() return 0. More...

uint size () const
 Return size of the bit array. More...

void set (sint bitNumber, bool value)
 Set a bit to 0 or 1. More...

bool get (sint bitNumber) const
 Get the value of a bit. More...

bool operator[] (sint bitNumber) const
 Get the value of a bit. More...

void set (sint bitNumber)
 Set a bit to 1. More...

void clear (sint bitNumber)
 Set a bit to 0. More...

void setAll ()
 Set all bits to 1. More...

void clearAll ()
 Set all bits to 0. More...

Bit operations.
CBitSet operator~ () const
 Return The bitarray NOTed. More...

CBitSet operator & (const CBitSet &bs) const
 Return this ANDed with bs. More...

CBitSet operator| (const CBitSet &bs) const
 Return this ORed with bs. More...

CBitSet operator^ (const CBitSet &bs) const
 Return this XORed with bs. More...

void flip ()
 NOT the BitArray. More...

CBitSet & operator &= (const CBitSet &bs)
 AND the bitArray with bs. More...

CBitSet & operator|= (const CBitSet &bs)
 OR the bitArray with bs. More...

CBitSet & operator^= (const CBitSet &bs)
 XOR the bitArray with bs. More...

Bit comparisons.
bool compareRestrict (const CBitSet &bs) const
 Compare two BitSet not necessarely of same size. More...

bool operator== (const CBitSet &bs) const
 Compare two BitSet. If not of same size, return false. More...

bool operator!= (const CBitSet &bs) const
 operator!=. More...

bool allSet ()
 Return true if all bits are set. false if size()==0. More...

bool allCleared ()
 Return true if all bits are cleared. false if size()==0. More...


Private Attributes

std::vector< uint32Array
sint NumBits
uint32 MaskLast


Detailed Description

A BitSet, to test / set flags quickly.

Author:
Lionel Berenguier , Nevrax France
Date:
2000

Definition at line 49 of file bit_set.h.


Constructor & Destructor Documentation

NLMISC::CBitSet::CBitSet  
 

Definition at line 44 of file bit_set.cpp.

References MaskLast, and NumBits.

Referenced by operator &, operator^, operator|, and operator~.

NLMISC::CBitSet::CBitSet uint    numBits
 

Definition at line 49 of file bit_set.cpp.

References MaskLast, NumBits, and resize.

NLMISC::CBitSet::CBitSet const CBitSet &    bs
 

Definition at line 55 of file bit_set.cpp.

References Array, MaskLast, and NumBits.

NLMISC::CBitSet::~CBitSet  
 

Definition at line 61 of file bit_set.cpp.


Member Function Documentation

bool NLMISC::CBitSet::allCleared  
 

Return true if all bits are cleared. false if size()==0.

Definition at line 282 of file bit_set.cpp.

References Array, and NumBits.

bool NLMISC::CBitSet::allSet  
 

Return true if all bits are set. false if size()==0.

Definition at line 269 of file bit_set.cpp.

References Array, MaskLast, and NumBits.

void NLMISC::CBitSet::clear sint    bitNumber [inline]
 

Set a bit to 0.

Definition at line 100 of file bit_set.h.

References set.

void NLMISC::CBitSet::clear  
 

Clear the bitarray so size() return 0.

Definition at line 75 of file bit_set.cpp.

References Array, MaskLast, and NumBits.

Referenced by NL3D::IAnimatable::clearFlag, resize, and resizeNoReset.

void NLMISC::CBitSet::clearAll  
 

Set all bits to 0.

Definition at line 127 of file bit_set.cpp.

References Array.

Referenced by NL3D::IModel::cleanTouch, and resize.

bool NLMISC::CBitSet::compareRestrict const CBitSet &    bs const
 

Compare two BitSet not necessarely of same size.

The comparison is done on N bits, where N=min(this->size(), bs.size())

Returns:
true if the N common bits of this and bs are the same. false otherwise.

Definition at line 242 of file bit_set.cpp.

References Array, min, NL_BITLEN, and NumBits.

void NLMISC::CBitSet::flip  
 

NOT the BitArray.

Definition at line 169 of file bit_set.cpp.

References Array, MaskLast, and NumBits.

bool NLMISC::CBitSet::get sint    bitNumber const [inline]
 

Get the value of a bit.

Definition at line 84 of file bit_set.h.

References Array, NL_BITLEN, NL_BITLEN_SHIFT, nlassert, and NumBits.

Referenced by operator[], and serial.

CBitSet NLMISC::CBitSet::operator & const CBitSet &    bs const
 

Return this ANDed with bs.

The result BitSet is of size of *this. Any missing bits into bs will be considered as 0.

Definition at line 142 of file bit_set.cpp.

References CBitSet.

CBitSet & NLMISC::CBitSet::operator &= const CBitSet &    bs
 

AND the bitArray with bs.

The bitset size is not changed. Any missing bits into bs will be considered as 0.

Definition at line 179 of file bit_set.cpp.

References Array, MaskLast, min, and NumBits.

bool NLMISC::CBitSet::operator!= const CBitSet &    bs const
 

operator!=.

Definition at line 238 of file bit_set.cpp.

References operator==.

CBitSet & NLMISC::CBitSet::operator= const CBitSet &    bs
 

Definition at line 64 of file bit_set.cpp.

References Array, MaskLast, and NumBits.

bool NLMISC::CBitSet::operator== const CBitSet &    bs const
 

Compare two BitSet. If not of same size, return false.

Definition at line 226 of file bit_set.cpp.

References Array, and NumBits.

Referenced by operator!=.

bool NLMISC::CBitSet::operator[] sint    bitNumber const [inline]
 

Get the value of a bit.

Definition at line 93 of file bit_set.h.

References get.

CBitSet NLMISC::CBitSet::operator^ const CBitSet &    bs const
 

Return this XORed with bs.

The result BitSet is of size of *this. Any missing bits into bs will be considered as 0.

Definition at line 158 of file bit_set.cpp.

References CBitSet.

CBitSet & NLMISC::CBitSet::operator^= const CBitSet &    bs
 

XOR the bitArray with bs.

The bitset size is not changed. Any missing bits into bs will be considered as 0.

Definition at line 209 of file bit_set.cpp.

References Array, MaskLast, min, and NumBits.

CBitSet NLMISC::CBitSet::operator| const CBitSet &    bs const
 

Return this ORed with bs.

The result BitSet is of size of *this. Any missing bits into bs will be considered as 0.

Definition at line 150 of file bit_set.cpp.

References CBitSet.

CBitSet & NLMISC::CBitSet::operator|= const CBitSet &    bs
 

OR the bitArray with bs.

The bitset size is not changed. Any missing bits into bs will be considered as 0.

Definition at line 195 of file bit_set.cpp.

References Array, MaskLast, min, and NumBits.

CBitSet NLMISC::CBitSet::operator~   const
 

Return The bitarray NOTed.

Definition at line 134 of file bit_set.cpp.

References CBitSet.

void NLMISC::CBitSet::resize uint    numBits
 

Resize the bit array. All Bits are reseted.

Definition at line 81 of file bit_set.cpp.

References Array, clear, clearAll, MaskLast, NL_BITLEN, and NumBits.

Referenced by CBitSet, NL3D::CTransform::CTransform, NL3D::IModel::IModel, and serial.

void NLMISC::CBitSet::resizeNoReset uint    numBits,
bool    value = false
 

Resize the bit array. Bits are not reseted. New bits are set with value.

Definition at line 98 of file bit_set.cpp.

References Array, clear, MaskLast, NL_BITLEN, NumBits, set, and value.

Referenced by NL3D::IAnimatable::resize.

void NLMISC::CBitSet::serial NLMISC::IStream   f
 

Definition at line 296 of file bit_set.cpp.

References get, resize, set, and size.

void NLMISC::CBitSet::set sint    bitNumber [inline]
 

Set a bit to 1.

Definition at line 98 of file bit_set.h.

References set.

void NLMISC::CBitSet::set sint    bitNumber,
bool    value
[inline]
 

Set a bit to 0 or 1.

Definition at line 72 of file bit_set.h.

References Array, NL_BITLEN, NL_BITLEN_SHIFT, nlassert, NumBits, and value.

Referenced by clear, NL3D::IModel::foul, resizeNoReset, serial, set, and NL3D::IAnimatable::touch.

void NLMISC::CBitSet::setAll  
 

Set all bits to 1.

Definition at line 121 of file bit_set.cpp.

References Array, and MaskLast.

uint NLMISC::CBitSet::size   const
 

Return size of the bit array.

Definition at line 117 of file bit_set.cpp.

References NumBits.

Referenced by serial.


Member Data Documentation

std::vector<uint32> NLMISC::CBitSet::Array [private]
 

Definition at line 169 of file bit_set.h.

Referenced by allCleared, allSet, CBitSet, clear, clearAll, compareRestrict, flip, get, operator &=, operator=, operator==, operator^=, operator|=, resize, resizeNoReset, set, and setAll.

uint32 NLMISC::CBitSet::MaskLast [private]
 

Definition at line 171 of file bit_set.h.

Referenced by allSet, CBitSet, clear, flip, operator &=, operator=, operator^=, operator|=, resize, resizeNoReset, and setAll.

sint NLMISC::CBitSet::NumBits [private]
 

Definition at line 170 of file bit_set.h.

Referenced by allCleared, allSet, CBitSet, clear, compareRestrict, flip, get, operator &=, operator=, operator==, operator^=, operator|=, resize, resizeNoReset, set, and size.


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