CrystalSpace

Public API Reference

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

csBitArray Class Reference

A one-dimensional array of bits, similar to STL bitset. More...

#include <csutil/bitarray.h>

List of all members.

Public Member Functions

 csBitArray ()
 Defalut constructor.
 csBitArray (size_t size)
 Construct with a size of size bits.
 csBitArray (const csBitArray &that)
 Construct as duplicate of that (copy constructor).
virtual ~csBitArray ()
 Destructor.
size_t Length () const
 Return the number of stored bits.
void SetLength (size_t newSize)
 Set the number of stored bits.
csBitArray & operator= (const csBitArray &that)
 Copy from other array.
BitProxy operator[] (size_t pos)
 Return bit at position pos.
const BitProxy operator[] (size_t pos) const
 Return bit at position pos.
bool operator== (const csBitArray &that) const
 Equal to other array.
bool operator!= (const csBitArray &that) const
 Not equal to other array.
csBitArray & operator &= (const csBitArray &that)
 Bit-wise `and'.
csBitArray operator|= (const csBitArray &that)
 Bit-wise `or'.
csBitArray operator^= (const csBitArray &that)
 Bit-wise `xor'.
csBitArray operator~ () const
 Return complement bit array in which all bits are flipped from this one.
void Clear ()
 Set all bits to false.
void SetBit (size_t pos)
 Set the bit at position pos to true.
void ClearBit (size_t pos)
 Set the bit at position pos to false.
void FlipBit (size_t pos)
 Toggle the bit at position pos.
void Set (size_t pos, bool val)
 Set the bit at position pos to the given value.
bool IsBitSet (size_t pos) const
 Returns true if the bit at position pos is true.
bool AreSomeBitsSet (size_t pos, size_t count) const
 Checks whether at least one of count bits is set from position pos on.
bool AllBitsFalse () const
 Returns true iff all bits are false.
csBitArray & FlipAllBits ()
 Change value of all bits.
store_type * GetArrayBits ()
 Return the full array.
store_type GetSingleWord ()
 Gets quick access to the single-word (only useful when the bit array <= the word size of the machine.).
void SetSingleWord (store_type sw)
 Sets the single-word very simply (only useful when the bit array <= the word size of the machine.).

Friends

csBitArray operator & (const csBitArray &a1, const csBitArray &a2)
 Bit-wise `and'.
csBitArray operator| (const csBitArray &a1, const csBitArray &a2)
 Bit-wise `or'.
csBitArray operator^ (const csBitArray &a1, const csBitArray &a2)
 Bit-wise `xor'.


Detailed Description

A one-dimensional array of bits, similar to STL bitset.

Definition at line 38 of file bitarray.h.


Constructor & Destructor Documentation

csBitArray::csBitArray (   )  [inline]
 

Defalut constructor.

Definition at line 154 of file bitarray.h.

Referenced by operator~().

csBitArray::csBitArray (  size_t  size  )  [inline, explicit]
 

Construct with a size of size bits.

Definition at line 164 of file bitarray.h.

csBitArray::csBitArray (  const csBitArray &  that  )  [inline]
 

Construct as duplicate of that (copy constructor).

Definition at line 175 of file bitarray.h.

virtual csBitArray::~csBitArray (   )  [inline, virtual]
 

Destructor.

Definition at line 182 of file bitarray.h.


Member Function Documentation

bool csBitArray::AllBitsFalse (   )  const [inline]
 

Returns true iff all bits are false.

Definition at line 372 of file bitarray.h.

bool csBitArray::AreSomeBitsSet (  size_t  pos,
size_t  count
)  const [inline]
 

Checks whether at least one of count bits is set from position pos on.

Definition at line 352 of file bitarray.h.

void csBitArray::Clear (   )  [inline]
 

Set all bits to false.

Definition at line 309 of file bitarray.h.

void csBitArray::ClearBit (  size_t  pos  )  [inline]
 

Set the bit at position pos to false.

Definition at line 322 of file bitarray.h.

Referenced by Set().

csBitArray& csBitArray::FlipAllBits (   )  [inline]
 

Change value of all bits.

Definition at line 381 of file bitarray.h.

Referenced by operator~().

void csBitArray::FlipBit (  size_t  pos  )  [inline]
 

Toggle the bit at position pos.

Definition at line 329 of file bitarray.h.

store_type* csBitArray::GetArrayBits (   )  [inline]
 

Return the full array.

Definition at line 391 of file bitarray.h.

store_type csBitArray::GetSingleWord (   )  [inline]
 

Gets quick access to the single-word (only useful when the bit array <= the word size of the machine.).

Definition at line 400 of file bitarray.h.

bool csBitArray::IsBitSet (  size_t  pos  )  const [inline]
 

Returns true if the bit at position pos is true.

Definition at line 342 of file bitarray.h.

size_t csBitArray::Length (   )  const [inline]
 

Return the number of stored bits.

Definition at line 189 of file bitarray.h.

csBitArray& csBitArray::operator &= (  const csBitArray &  that  )  [inline]
 

Bit-wise `and'.

Definition at line 254 of file bitarray.h.

References mNumBits, and mpStore.

bool csBitArray::operator!= (  const csBitArray &  that  )  const [inline]
 

Not equal to other array.

Definition at line 248 of file bitarray.h.

csBitArray& csBitArray::operator= (  const csBitArray &  that  )  [inline]
 

Copy from other array.

Definition at line 211 of file bitarray.h.

References mNumBits, and mpStore.

bool csBitArray::operator== (  const csBitArray &  that  )  const [inline]
 

Equal to other array.

Definition at line 236 of file bitarray.h.

References mNumBits, and mpStore.

const BitProxy csBitArray::operator[] (  size_t  pos  )  const [inline]
 

Return bit at position pos.

Definition at line 229 of file bitarray.h.

BitProxy csBitArray::operator[] (  size_t  pos  )  [inline]
 

Return bit at position pos.

Definition at line 222 of file bitarray.h.

csBitArray csBitArray::operator^= (  const csBitArray &  that  )  [inline]
 

Bit-wise `xor'.

Definition at line 272 of file bitarray.h.

References mNumBits, and mpStore.

csBitArray csBitArray::operator|= (  const csBitArray &  that  )  [inline]
 

Bit-wise `or'.

Definition at line 263 of file bitarray.h.

References mNumBits, and mpStore.

csBitArray csBitArray::operator~ (   )  const [inline]
 

Return complement bit array in which all bits are flipped from this one.

Definition at line 281 of file bitarray.h.

References csBitArray(), and FlipAllBits().

void csBitArray::Set (  size_t  pos,
bool  val
)  [inline]
 

Set the bit at position pos to the given value.

Definition at line 336 of file bitarray.h.

References ClearBit(), and SetBit().

void csBitArray::SetBit (  size_t  pos  )  [inline]
 

Set the bit at position pos to true.

Definition at line 315 of file bitarray.h.

Referenced by Set().

void csBitArray::SetLength (  size_t  newSize  )  [inline]
 

Set the number of stored bits.

Remarks:
If the new size is larger than the old size, the newly added bits are cleared.

Definition at line 199 of file bitarray.h.

void csBitArray::SetSingleWord (  store_type  sw  )  [inline]
 

Sets the single-word very simply (only useful when the bit array <= the word size of the machine.).

Definition at line 409 of file bitarray.h.


Friends And Related Function Documentation

csBitArray operator & (  const csBitArray &  a1,
const csBitArray &  a2
)  [friend]
 

Bit-wise `and'.

Definition at line 287 of file bitarray.h.

csBitArray operator^ (  const csBitArray &  a1,
const csBitArray &  a2
)  [friend]
 

Bit-wise `xor'.

Definition at line 299 of file bitarray.h.

csBitArray operator| (  const csBitArray &  a1,
const csBitArray &  a2
)  [friend]
 

Bit-wise `or'.

Definition at line 293 of file bitarray.h.


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.3.9.1