Equity
Bitcoin Protocol Library
Public Member Functions | List of all members
P2p::BitArray Class Reference

An array of bits. More...

#include <Serialize.h>

Inheritance diagram for P2p::BitArray:
P2p::Serializable

Public Member Functions

 BitArray (size_t size)
 
 BitArray (uint8_t const *&in, size_t &size)
 
bool get (size_t index) const
 Returns the value of the bit at the given index.
 
void set (size_t index, bool value=true)
 Sets the value of the bit at the given index. More...
 
void reset (size_t index)
 Sets the value of the bit at the given index to false. More...
 
void flip (size_t index)
 Flips the value of the bit at the given index. More...
 
bool operator[] (size_t index) const
 Returns the value of the bit at the given index. More...
 
Overrides Serializable
virtual void serialize (std::vector< uint8_t > &out) const override
 
virtual json toJson () const override
 

Detailed Description

An array of bits.

This is primarily used for serialization of an array of bits along with the number of bits in the array.

See also
VASize, VarArray

Constructor & Destructor Documentation

P2p::BitArray::BitArray ( size_t  size)
inline
Parameters
sizeSize of the array in bits
P2p::BitArray::BitArray ( uint8_t const *&  in,
size_t &  size 
)
Parameters
[in,out]inpointer to the next byte to deserialize
[in,out]sizenumber of bytes remaining in the serialized stream

Member Function Documentation

void P2p::BitArray::flip ( size_t  index)
inline

Flips the value of the bit at the given index.

Parameters
indexWhich bit to flip
bool P2p::BitArray::operator[] ( size_t  index) const
inline

Returns the value of the bit at the given index.

Parameters
indexWhich bit to get
void P2p::BitArray::reset ( size_t  index)
inline

Sets the value of the bit at the given index to false.

Parameters
indexWhich bit to reset
void P2p::BitArray::set ( size_t  index,
bool  value = true 
)

Sets the value of the bit at the given index.

Parameters
indexWhich bit to set
valueValue to set the bit to (defaults to true)

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