# 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<uintArray
sint NumBits
uint MaskLast


Detailed Description

A BitSet, to test / set flags quickly.

Author(s):
Lionel Berenguier , Nevrax France
Date:
2000

Definition at line 45 of file bit_set.h.


Constructor & Destructor Documentation

NLMISC::CBitSet::CBitSet ( )
 

Definition at line 46 of file bit_set.cpp.

NLMISC::CBitSet::CBitSet ( uint numBits )
 

Definition at line 51 of file bit_set.cpp.

NLMISC::CBitSet::CBitSet ( const CBitSet & bs )
 

Definition at line 57 of file bit_set.cpp.

NLMISC::CBitSet::~CBitSet ( )
 

Definition at line 63 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 311 of file bit_set.cpp.

bool NLMISC::CBitSet::allSet ( )
 

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

Definition at line 298 of file bit_set.cpp.

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

Set a bit to 0.

Definition at line 76 of file bit_set.h.

void NLMISC::CBitSet::clear ( void )
 

Clear the bitarray so size() return 0.

Definition at line 77 of file bit_set.cpp.

Referenced by NL3D::IAnimatable::clearFlag().

void NLMISC::CBitSet::clearAll ( )
 

Set all bits to 0.

Definition at line 156 of file bit_set.cpp.

Referenced by NL3D::IModel::cleanTouch().

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 271 of file bit_set.cpp.

void NLMISC::CBitSet::flip ( )
 

NOT the BitArray.

Definition at line 198 of file bit_set.cpp.

bool NLMISC::CBitSet::get ( sint bitNumber ) const
 

Get the value of a bit.

Definition at line 134 of file bit_set.cpp.

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 171 of file bit_set.cpp.

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 208 of file bit_set.cpp.

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

operator!=.

Definition at line 267 of file bit_set.cpp.

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

Definition at line 66 of file bit_set.cpp.

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

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

Definition at line 255 of file bit_set.cpp.

bool NLMISC::CBitSet::operator[] ( sint bitNumber ) const
 

Get the value of a bit.

Definition at line 142 of file bit_set.cpp.

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 187 of file bit_set.cpp.

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 238 of file bit_set.cpp.

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 179 of file bit_set.cpp.

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 224 of file bit_set.cpp.

CBitSet NLMISC::CBitSet::operator~ ( ) const
 

Return The bitarray NOTed.

Definition at line 163 of file bit_set.cpp.

void NLMISC::CBitSet::resize ( uint numBits )
 

Resize the bit array. All Bits are reseted.

Definition at line 83 of file bit_set.cpp.

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 100 of file bit_set.cpp.

void NLMISC::CBitSet::serial ( NLMISC::IStream & f )
 

Definition at line 325 of file bit_set.cpp.

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

Set a bit to 1.

Definition at line 74 of file bit_set.h.

void NLMISC::CBitSet::set ( sint bitNumber,
bool value )
 

Set a bit to 0 or 1.

Definition at line 123 of file bit_set.cpp.

Referenced by NL3D::IModel::foul(), and NL3D::IAnimatable::propagateTouch().

void NLMISC::CBitSet::setAll ( )
 

Set all bits to 1.

Definition at line 150 of file bit_set.cpp.

uint NLMISC::CBitSet::size ( ) const
 

Return size of the bit array.

Definition at line 119 of file bit_set.cpp.


Member Data Documentation

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

Definition at line 145 of file bit_set.h.

uint NLMISC::CBitSet::MaskLast [private]
 

Definition at line 147 of file bit_set.h.

sint NLMISC::CBitSet::NumBits [private]
 

Definition at line 146 of file bit_set.h.


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