libktorrent  2.1.1
Public Member Functions | Static Public Attributes | List of all members
bt::BitSet Class Reference

Simple implementation of a BitSet. More...

#include <bitset.h>

Public Member Functions

 BitSet (const BitSet &bs)
 
 BitSet (const Uint8 *data, Uint32 num_bits)
 
 BitSet (Uint32 num_bits=8)
 
bool allOn () const
 Check if all bit are set to 1.
 
void andBitSet (const BitSet &other)
 
void clear ()
 
bool get (Uint32 i) const
 
Uint8 * getData ()
 
const Uint8 * getData () const
 
Uint32 getNumBits () const
 
Uint32 getNumBytes () const
 
bool includesBitSet (const BitSet &other)
 
void invert ()
 
bool isNull () const
 See if the BitSet is null.
 
Uint32 numOnBits () const
 Get the number of on bits.
 
bool operator!= (const BitSet &bs) const
 
BitSet operator- (const BitSet &bs) const
 
BitSetoperator-= (const BitSet &bs)
 
BitSetoperator= (const BitSet &bs)
 
bool operator== (const BitSet &bs) const
 
void orBitSet (const BitSet &other)
 
void set (Uint32 i, bool on)
 
void setAll (bool on)
 Set all bits on or off.
 
void updateNumOnBits ()
 

Static Public Attributes

static BitSet null
 

Detailed Description

Author
Joris Guisson Simple implementation of a BitSet, can only turn on and off bits. BitSet's are used to indicate which chunks we have or not.

Definition at line 54 of file bitset.h.

Constructor & Destructor Documentation

◆ BitSet() [1/3]

bt::BitSet::BitSet ( Uint32  num_bits = 8)

Constructor.

Parameters
num_bitsThe number of bits

◆ BitSet() [2/3]

bt::BitSet::BitSet ( const Uint8 *  data,
Uint32  num_bits 
)

Manually set data.

Parameters
dataThe data
num_bitsThe number of bits

◆ BitSet() [3/3]

bt::BitSet::BitSet ( const BitSet bs)

Copy constructor.

Parameters
bsBitSet to copy
Returns

Member Function Documentation

◆ andBitSet()

void bt::BitSet::andBitSet ( const BitSet other)

and this BitSet with another.

Parameters
otherThe other BitSet

◆ clear()

void bt::BitSet::clear ( )

Set all bits to 0

◆ get()

bool bt::BitSet::get ( Uint32  i) const
inline

Get the value of a bit, false means 0, true 1.

Parameters
iIndex of Bit

Definition at line 180 of file bitset.h.

◆ includesBitSet()

bool bt::BitSet::includesBitSet ( const BitSet other)

see if this BitSet includes another.

Parameters
otherThe other BitSet

◆ invert()

void bt::BitSet::invert ( )

invert this BitSet

◆ operator!=()

bool bt::BitSet::operator!= ( const BitSet bs) const
inline

Opposite of operator ==

Definition at line 188 of file bitset.h.

◆ operator-()

BitSet bt::BitSet::operator- ( const BitSet bs) const

Subtraction operator.

Parameters
bsBitSet to subtract from this one
Returns
difference

◆ operator-=()

BitSet& bt::BitSet::operator-= ( const BitSet bs)

Subtraction assignment operator.

Parameters
bsBitSet to copy and subtract from this one
Returns
*this

◆ operator=()

BitSet& bt::BitSet::operator= ( const BitSet bs)

Assignment operator.

Parameters
bsBitSet to copy
Returns
*this

◆ operator==()

bool bt::BitSet::operator== ( const BitSet bs) const

Check for equality of bitsets

Parameters
bsBitSet to compare
Returns
true if equal

◆ orBitSet()

void bt::BitSet::orBitSet ( const BitSet other)

or this BitSet with another.

Parameters
otherThe other BitSet

◆ set()

void bt::BitSet::set ( Uint32  i,
bool  on 
)
inline

Set the value of a bit, false means 0, true 1.

Parameters
iIndex of Bit
onFalse means 0, true 1

Definition at line 191 of file bitset.h.

◆ updateNumOnBits()

void bt::BitSet::updateNumOnBits ( )

Update the number of on bits


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