isomatch
Classes | Public Member Functions | Friends | List of all members
DynBitset Class Reference

#include <dyn_bitset.h>

Classes

class  Reference
 
class  SizeMismatch
 

Public Member Functions

 DynBitset (size_t size)
 size is expressed in bits. Initializes to zeroes. More...
 
 DynBitset (const DynBitset &oth)
 
 ~DynBitset ()
 
void operator= (const DynBitset &oth)
 
DynBitsetoperator= (DynBitset &&oth)=delete
 
size_t size () const
 
bool operator[] (size_t pos) const
 Constant bit access operator. More...
 
Reference operator[] (size_t pos)
 Alterable bit reference. More...
 
DynBitsetoperator&= (const DynBitset &oth)
 
DynBitsetoperator|= (const DynBitset &oth)
 In-place bitwise or. More...
 
DynBitsetoperator^= (const DynBitset &oth)
 In-place bitwise xor. More...
 
DynBitsetflip ()
 In-place bitwise flip. More...
 
DynBitset operator& (const DynBitset &oth) const
 Bitwise AND of two DynBitsets. More...
 
DynBitset operator| (const DynBitset &oth) const
 Bitwise OR of two DynBitsets. More...
 
DynBitset operator^ (const DynBitset &oth) const
 Bitwise XOR of two DynBitsets. More...
 
DynBitset operator~ () const
 Bitwise flip. More...
 
void reset ()
 Sets all bits to false. More...
 
bool any () const
 Checks if any bit is true. More...
 
bool anyOver (size_t pos) const
 Checks if any bit above the posth (incl.) is true. More...
 
int singleBit () const
 Checks if a single bit is set. More...
 
std::string dump () const
 Dumps the DynBitset to an hex representation. More...
 

Friends

class Reference
 

Detailed Description

Dynamically sized bitset

Makes up for the lack of a std::bitset equivalent that can have runtime-defined size. std::vector<bool> does not support efficient bitwise operations, and is not well-defined apart from "more space-efficient" (leaves a great deal of liberty to the implementation).

The size of the bitset must be known at allocation time, and cannot be changed afterwards (apart from copying the bitset to a freshly allocated one).

Constructor & Destructor Documentation

◆ DynBitset() [1/2]

DynBitset::DynBitset ( size_t  size)

size is expressed in bits. Initializes to zeroes.

◆ DynBitset() [2/2]

DynBitset::DynBitset ( const DynBitset oth)

◆ ~DynBitset()

DynBitset::~DynBitset ( )

Member Function Documentation

◆ any()

bool DynBitset::any ( ) const

Checks if any bit is true.

◆ anyOver()

bool DynBitset::anyOver ( size_t  pos) const

Checks if any bit above the posth (incl.) is true.

◆ dump()

std::string DynBitset::dump ( ) const

Dumps the DynBitset to an hex representation.

◆ flip()

DynBitset & DynBitset::flip ( )

In-place bitwise flip.

◆ operator&()

DynBitset DynBitset::operator & ( const DynBitset oth) const

Bitwise AND of two DynBitsets.

◆ operator&=()

DynBitset & DynBitset::operator &= ( const DynBitset oth)

◆ operator=() [1/2]

void DynBitset::operator= ( const DynBitset oth)

◆ operator=() [2/2]

DynBitset& DynBitset::operator= ( DynBitset &&  oth)
delete

◆ operator[]() [1/2]

bool DynBitset::operator[] ( size_t  pos) const
inline

Constant bit access operator.

◆ operator[]() [2/2]

DynBitset::Reference DynBitset::operator[] ( size_t  pos)

Alterable bit reference.

In-place bitwise and

◆ operator^()

DynBitset DynBitset::operator^ ( const DynBitset oth) const

Bitwise XOR of two DynBitsets.

◆ operator^=()

DynBitset & DynBitset::operator^= ( const DynBitset oth)

In-place bitwise xor.

◆ operator|()

DynBitset DynBitset::operator| ( const DynBitset oth) const

Bitwise OR of two DynBitsets.

◆ operator|=()

DynBitset & DynBitset::operator|= ( const DynBitset oth)

In-place bitwise or.

◆ operator~()

DynBitset DynBitset::operator~ ( ) const

Bitwise flip.

◆ reset()

void DynBitset::reset ( )

Sets all bits to false.

◆ singleBit()

int DynBitset::singleBit ( ) const

Checks if a single bit is set.

Checks whether a single bit is set. If so, returns this bit's position; if no or multiple bits are set, returns -1.

◆ size()

size_t DynBitset::size ( ) const
inline

Friends And Related Function Documentation

◆ Reference

friend class Reference
friend

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