## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# csBitArray Class Reference

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

`#include <csutil/bitarray.h>`

List of all members.

## Public Types

typedef unsigned long | store_type

## Public Member Functions

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

## Friends

class | BitProxy
class | csComparator< csBitArray, csBitArray >
class | csHashComputer< csBitArray >
csBitArray | operator & (const csBitArray &a1, const csBitArray &a2)
| Bit-wise `and'. The arrays must be the same length.
csBitArray | operator^ (const csBitArray &a1, const csBitArray &a2)
| Bit-wise `xor'. The arrays must be the same length.
csBitArray | operator| (const csBitArray &a1, const csBitArray &a2)
| Bit-wise `or'. The arrays must be the same length.

## Classes

class | BitProxy

## Detailed Description

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

Definition at line 44 of file bitarray.h.

## Constructor & Destructor Documentation

csBitArray::csBitArray | ( |  | ) | `[inline]`

| Default constructor. Definition at line 150 of file bitarray.h.

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

| Construct with a size of size bits. Definition at line 158 of file bitarray.h.

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

| Construct as duplicate of that (copy constructor). Definition at line 167 of file bitarray.h.

csBitArray::~csBitArray | ( |  | ) | `[inline]`

| Destructor. Definition at line 174 of file bitarray.h.

## Member Function Documentation

bool csBitArray::AllBitsFalse | ( |  | ) | const`[inline]`

| Returns true if all bits are false. Definition at line 429 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 starting at pos. Definition at line 409 of file bitarray.h. References CS_ASSERT. Referenced by csBlockAllocator< csBSPTree >::Compact().

void csBitArray::Clear | ( |  | ) | `[inline]`

| Set all bits to false. Definition at line 365 of file bitarray.h.

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

| Set the bit at position pos to false. Definition at line 378 of file bitarray.h. References CS_ASSERT.

void csBitArray::Delete | ( | size_t | pos,
|  | size_t | count
| ) | `[inline]`

| Delete from the array count bits starting at pos, making the array shorter. Definition at line 452 of file bitarray.h. References CS_ASSERT. Referenced by csBlockAllocator< csBSPTree >::Compact().

csBitArray& csBitArray::FlipAllBits | ( |  | ) | `[inline]`

| Change value of all bits. Definition at line 439 of file bitarray.h.

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

| Toggle the bit at position pos. Definition at line 385 of file bitarray.h. References CS_ASSERT.

store_type* csBitArray::GetArrayBits | ( |  | ) | `[inline]`

| Return the full backing-store. Definition at line 481 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 490 of file bitarray.h. References CS_ASSERT.

size_t csBitArray::GetSize | ( |  | ) | const`[inline]`

| Return the number of stored bits. Definition at line 181 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 401 of file bitarray.h. References CS_ASSERT. Referenced by csBlockAllocator< csBSPTree >::DisposeAll(), and csBitArray::BitProxy::operator=().

size_t csBitArray::Length | ( |  | ) | const`[inline]`

Return the number of stored bits.

Deprecated:
  Use GetSize() instead.

Definition at line 190 of file bitarray.h.

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

| Bit-wise `and'. The arrays must be the same length. Definition at line 304 of file bitarray.h. References CS_ASSERT, GetStore(), and mNumBits.

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

| Not equal to other array? Definition at line 298 of file bitarray.h.

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

| Copy from other array. Definition at line 260 of file bitarray.h. References GetStore(), and mNumBits.

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

| Equal to other array? Definition at line 284 of file bitarray.h. References GetStore(), and mNumBits.

bool csBitArray::operator[] | ( | size_t | pos | ) | const`[inline]`

| Return bit at position pos. Definition at line 278 of file bitarray.h.

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

| Return bit at position pos. Definition at line 271 of file bitarray.h. References CS_ASSERT.

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

| Bit-wise `xor'. The arrays must be the same length. Definition at line 326 of file bitarray.h. References CS_ASSERT, GetStore(), and mNumBits.

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

| Bit-wise `or'. The arrays must be the same length. Definition at line 315 of file bitarray.h. References CS_ASSERT, GetStore(), and mNumBits.

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

| Return complement bit array in which all bits are flipped from this one. Definition at line 337 of file bitarray.h.

void csBitArray::Set | ( | size_t | pos,
|  | bool | val = `true`
| ) | `[inline]`

| Set the bit at position pos to the given value. Definition at line 392 of file bitarray.h.

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

| Set the bit at position pos to true. Definition at line 371 of file bitarray.h. References CS_ASSERT. Referenced by Slice().

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

Set the number of stored bits.

Deprecated:
  Use SetSize() instead.

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 500 of file bitarray.h. References CS_ASSERT.

void csBitArray::SetSize | ( | 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 209 of file bitarray.h.

csBitArray csBitArray::Slice | ( | size_t | pos,
|  | size_t | count
| ) | const`[inline]`

| Return a new bit array containing a slice count bits in length from this array starting at pos. Does not modify this array. Definition at line 470 of file bitarray.h. References CS_ASSERT, and SetBit().

## Friends And Related Function Documentation

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

| Bit-wise `and'. The arrays must be the same length. Definition at line 343 of file bitarray.h.

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

| Bit-wise `xor'. The arrays must be the same length. Definition at line 355 of file bitarray.h.

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

| Bit-wise `or'. The arrays must be the same length. Definition at line 349 of file bitarray.h.

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

- csutil/bitarray.h