libHSPlasma
Classes | Public Member Functions | List of all members
hsBitVector Class Reference

Stores an array (vector) of bits. More...

#include <hsBitVector.h>

Classes

class  Bit
 References an individual bit within an hsBitVector. More...

Public Member Functions

 hsBitVector ()
 hsBitVector (const hsBitVector &init)
 ~hsBitVector ()
bool get (unsigned int idx) const
void set (unsigned int idx, bool b)
size_t size () const
bool operator[] (unsigned int idx) const
Bit operator[] (unsigned int idx)
hsBitVectoroperator= (const hsBitVector &cpy)
bool isEmpty () const
void clear ()
void setBit (unsigned int idx)
void clearBit (unsigned int idx)
void compact ()
const char * getName (unsigned int idx)
unsigned int getValue (const char *name)
void setName (unsigned int idx, const char *name)
void read (hsStream *S)
void write (hsStream *S)
void prcWrite (pfPrcHelper *prc)
void prcParse (const pfPrcTag *tag)

Detailed Description

Stores an array (vector) of bits.

This can be used as a normal vector, but it allows direct access to numbered (or named) bits, e.g. for flags or a logical bitmap.

NOTE: In PyPlasma, this class has overloaded [] operators both for indexed and for named bits. For example:

bv.setName(3, 'Three')
bv['Three'] = True

Constructor & Destructor Documentation

hsBitVector::hsBitVector ( )

Constructs an empty bit vector

hsBitVector::hsBitVector ( const hsBitVector init)

Copy constructor

hsBitVector::~hsBitVector ( )

Destructor

Member Function Documentation

void hsBitVector::clear ( )

Clears the bit vector (set to all zeroes)

void hsBitVector::clearBit ( unsigned int  idx)

Sets the bit at idx to false

void hsBitVector::compact ( )

Clean up extra space in the bit vector. This is called automatically by write().

bool hsBitVector::get ( unsigned int  idx) const

Returns the value of bit idx

const char* hsBitVector::getName ( unsigned int  idx)

Returns the name of bit idx. If no name has been assigned with setName(), this function returns a string of idx.

unsigned int hsBitVector::getValue ( const char *  name)

Returns the bit index corresponding to bit name name. name can be either a name assigned with setName() or an integer, like getName() returns.

bool hsBitVector::isEmpty ( ) const

Returns true if the bit vector is empty (all zeroes)

hsBitVector& hsBitVector::operator= ( const hsBitVector cpy)

Assignment operator, copies the value of cpy

bool hsBitVector::operator[] ( unsigned int  idx) const

Return the value of bit idx, for const hsBitVectors

Bit hsBitVector::operator[] ( unsigned int  idx)

Return a Bit class referencing bit idx

void hsBitVector::prcParse ( const pfPrcTag tag)

Parse a Bit Vector from PRC source

void hsBitVector::prcWrite ( pfPrcHelper prc)

Write PRC source for the bit vector

void hsBitVector::read ( hsStream S)

Read this bit vector from a stream

void hsBitVector::set ( unsigned int  idx,
bool  b 
)

Set the value of bit idx to b

void hsBitVector::setBit ( unsigned int  idx)

Sets the bit at idx to true

void hsBitVector::setName ( unsigned int  idx,
const char *  name 
)

Sets the name of bit idx to name, for use in getName() and PyPlasma's overloaded [] operator.

size_t hsBitVector::size ( ) const

Return the number of available bits.

void hsBitVector::write ( hsStream S)

Write this bit vector to a stream


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