Base Module  VST 3.6.6
SDK for developing VST Plug-in
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Attributes
BitSet Class Reference

Bitset - A collection of bits. More...

#include <fbitset.h>

+ Inheritance diagram for BitSet:

Public Types

enum  ReturnTypes { kEmptySize = -2L, kBitNotFound = -1L }
 

Public Member Functions

 BitSet ()
 Default constructor (size is 0) More...
 
 BitSet (uint32 size)
 Constructor with a given size (number of wanted bits) More...
 
 BitSet (const BitSet &)
 Copy constructor. More...
 
virtual ~BitSet ()
 Virtual destructor. More...
 
BitSetoperator= (const BitSet &)
 Assignment operator. More...
 
bool operator== (const BitSet &)
 The equality operator. More...
 
bool operator!= (const BitSet &)
 The inequality operator. More...
 
BitSetoperator&= (const BitSet &toAnd)
 Bitwise and (AND), both bitsets needs to have the same size, otherwise nothing happens. More...
 
BitSetoperator|= (const BitSet &toOr)
 Bitwise inclusive or (OR), both bitsets needs to have the same size, otherwise nothing happens. More...
 
BitSetoperator^= (const BitSet &toXOr)
 Bitwise exclusive or (XOR), both bitsets needs to have the same size, otherwise nothing happens. More...
 
void setSize (uint32 size)
 Resize to then number of bits that the bitset can hold, resize to 0 is allowed (free all), allocate memory is rounded to next kChunkSize. More...
 
uint32 getSize () const
 Return the current size of the BitSet. More...
 
void setBit (uint32 which)
 Sets the bit (at 'which' position) to 1; resizes the bitSet if necessary when which > size. More...
 
void clearBit (uint32 which)
 Sets the bit (at 'which' position) to 0; resizes the bitSet if necessary when which > size. More...
 
void toggleBit (uint32 which)
 Changes the bits value (flip: 0=>1, 1=>0); resizes the bitSet if necessary when which > size. More...
 
void setAll ()
 Sets all bits to 1. More...
 
void clearAll ()
 Sets all bits to 0 (clears every bit) More...
 
bool getBit (uint32 which) const
 Returns if the bit (at 'which' position) is set to 1. More...
 
bool isEmpty () const
 Returns true, if no bit is set (all 0) More...
 
uint32 countSetBits (int32 toPos=-1) const
 Return the count of set bits from 0 to toPos position. More...
 
int64 getFirstSet () const
 Return the first found set bit (from 0 to size-1) or see ReturnTypes. More...
 
int64 getFirstNotSet () const
 Return the first found NOT set bit (from 0 to size-1) or see ReturnTypes. More...
 
int64 getLastSet () const
 Return the last found set bit (from size-1 to 0) or see ReturnTypes. More...
 

Protected Types

typedef uint32 BSChunkType
 

Protected Member Functions

virtual void onChange ()
 is called when bits are changed, derived classes can overwrite this. More...
 
uint32 getChunkCount () const
 Return the count of chunk currently used and allocate. More...
 
BSChunkType getChunk (uint32 n) const
 Return the wanted chunk by index (return 0 if not available) More...
 
void setChunk (uint32 n, BSChunkType chunk)
 Set/replace a given chunk. More...
 

Static Protected Attributes

static const uint32 kChunkSize = sizeof (BSChunkType) * 8
 
static const uint32 kChunkByteSize = sizeof (BSChunkType)
 
static const BSChunkType kFullChunk = 0xfffffffful
 

Detailed Description

Bitset - A collection of bits.

Individual indexed bits can be examined, set, or cleared. Its size is variable (grows as needed). One BitSet may be used to modify the contents of another BitSet through logical AND, logical inclusive OR, and logical exclusive OR operations. By default, all bits in the set initially have the value 0 (Not Set).

Note
Logical operations:
    0 AND 0 = 0     0 OR 0 = 0      0 XOR 0 = 0
    0 AND 1 = 0     0 OR 1 = 1      0 XOR 1 = 1
    1 AND 0 = 0     1 OR 0 = 1      1 XOR 0 = 1
    1 AND 1 = 1     1 OR 1 = 1      1 XOR 1 = 0

Member Typedef Documentation

typedef uint32 BSChunkType
protected

Member Enumeration Documentation

Enumerator
kEmptySize 

Return when the bitSet is empty when searching for a bit.

kBitNotFound 

Searched bit not found.

Constructor & Destructor Documentation

BitSet ( )

Default constructor (size is 0)

BitSet ( uint32  size)

Constructor with a given size (number of wanted bits)

BitSet ( const BitSet from)

Copy constructor.

~BitSet ( )
virtual

Virtual destructor.

Member Function Documentation

BitSet & operator= ( const BitSet from)

Assignment operator.

bool operator== ( const BitSet toCompare)

The equality operator.

bool operator!= ( const BitSet toCompare)

The inequality operator.

BitSet & operator&= ( const BitSet toAnd)

Bitwise and (AND), both bitsets needs to have the same size, otherwise nothing happens.

BitSet & operator|= ( const BitSet toOr)

Bitwise inclusive or (OR), both bitsets needs to have the same size, otherwise nothing happens.

BitSet & operator^= ( const BitSet toXOr)

Bitwise exclusive or (XOR), both bitsets needs to have the same size, otherwise nothing happens.

void setSize ( uint32  size)

Resize to then number of bits that the bitset can hold, resize to 0 is allowed (free all), allocate memory is rounded to next kChunkSize.

uint32 getSize ( ) const
inline

Return the current size of the BitSet.

void setBit ( uint32  which)

Sets the bit (at 'which' position) to 1; resizes the bitSet if necessary when which > size.

void clearBit ( uint32  which)

Sets the bit (at 'which' position) to 0; resizes the bitSet if necessary when which > size.

void toggleBit ( uint32  which)

Changes the bits value (flip: 0=>1, 1=>0); resizes the bitSet if necessary when which > size.

void setAll ( )

Sets all bits to 1.

void clearAll ( )

Sets all bits to 0 (clears every bit)

bool getBit ( uint32  which) const

Returns if the bit (at 'which' position) is set to 1.

bool isEmpty ( ) const

Returns true, if no bit is set (all 0)

uint32 countSetBits ( int32  toPos = -1) const

Return the count of set bits from 0 to toPos position.

int64 getFirstSet ( ) const

Return the first found set bit (from 0 to size-1) or see ReturnTypes.

int64 getFirstNotSet ( ) const

Return the first found NOT set bit (from 0 to size-1) or see ReturnTypes.

int64 getLastSet ( ) const

Return the last found set bit (from size-1 to 0) or see ReturnTypes.

virtual void onChange ( )
inlineprotectedvirtual

is called when bits are changed, derived classes can overwrite this.

uint32 getChunkCount ( ) const
inlineprotected

Return the count of chunk currently used and allocate.

BitSet::BSChunkType getChunk ( uint32  n) const
protected

Return the wanted chunk by index (return 0 if not available)

void setChunk ( uint32  n,
BitSet::BSChunkType  chunk 
)
protected

Set/replace a given chunk.

Field Documentation

const uint32 kChunkSize = sizeof (BSChunkType) * 8
staticprotected
const uint32 kChunkByteSize = sizeof (BSChunkType)
staticprotected
const BSChunkType kFullChunk = 0xfffffffful
staticprotected
Empty

Copyright ©2016 Steinberg Media Technologies GmbH. All Rights Reserved.