MOTION  0.01
Framework for mixed-protocol multi-party computation
Public Member Functions | List of all members
encrypto::motion::BitSpan Class Reference

Non-owning non-resizeable BitVector. More...

#include <bit_vector.h>

Public Member Functions

 BitSpan ()=default
 
 ~BitSpan ()=default
 
 BitSpan (const BitSpan &other)
 
 BitSpan (BitSpan &&other)
 
BitSpanoperator= (const BitSpan &other)
 
BitSpanoperator= (BitSpan &&other)
 
template<typename BitVectorType >
 BitSpan (BitVectorType &bit_vector)
 Construct a BitSpan from a BitVector. More...
 
template<typename BitVectorType >
BitSpanoperator= (BitVectorType &bit_vector)
 Assignment from BitVector. More...
 
 BitSpan (std::byte *buffer, std::size_t bit_size, bool aligned=false)
 Construct a BitSpan from std::byte buffer of length bit_size. More...
 
template<typename T >
 BitSpan (T *buffer, std::size_t bit_size, bool aligned=false)
 Construct a BitSpan from a buffer of length bit_size. More...
 
template<typename BitVectorType = AlignedBitVector>
BitVectorType As () const
 Converts this BitSpan to a BitVector. More...
 
template<typename BitVectorType = AlignedBitVector>
BitVectorType Subset (const std::size_t from, const std::size_t to) const
 Returns a new BitVector containing the bits of this BitSpan between positions from and to. More...
 
bool Empty () const noexcept
 Check if BitSpan is empty. More...
 
void Invert ()
 In-place bit-wise invert. More...
 
template<typename BitVectorType = AlignedBitVector>
BitVectorType operator~ () const
 Return a BitVector containing bit-inverted values of this BitSpan. More...
 
template<typename BitVectorType = AlignedBitVector>
bool operator== (const BitVectorType &other) const
 Compare the content of a BitVectorType for equality. More...
 
bool operator== (const BitSpan &other) const
 Compare the content with another BitSpan for equality. More...
 
template<typename BitVectorType = AlignedBitVector>
BitVectorType operator& (const BitVectorType &other) const
 Perform AND operation on every bit of BitSpan and BitVector. More...
 
template<typename BitVectorType = AlignedBitVector>
BitVectorType operator& (const BitSpan &other) const
 Perform AND operation on every bit of both BitSpans. More...
 
template<typename BitVectorType = AlignedBitVector>
BitVectorType operator| (const BitVectorType &other) const
 Perform OR operation on every bit of BitSpan and BitVector. More...
 
template<typename BitVectorType = AlignedBitVector>
BitVectorType operator| (const BitSpan &other) const
 Perform OR operation on every bit of both BitSpans. More...
 
template<typename BitVectorType = AlignedBitVector>
BitVectorType operator^ (const BitVectorType &other) const
 Perform XOR operation on every bit of BitSpan and BitVector. More...
 
template<typename BitVectorType = AlignedBitVector>
BitVectorType operator^ (const BitSpan &other) const
 Perform XOR operation on every bit of both BitSpans. More...
 
template<typename BitVectorType = AlignedBitVector>
BitSpanoperator&= (const BitVectorType &other)
 Perform AND-assign operation on every bit of BitSpan and BitVector. More...
 
BitSpanoperator&= (const BitSpan &other)
 Perform AND-assign operation on every bit of both BitSpans. More...
 
template<typename BitVectorType = AlignedBitVector>
BitSpanoperator|= (const BitVectorType &other)
 Perform OR-assign operation on every bit of BitSpan and BitVector. More...
 
BitSpanoperator|= (const BitSpan &other)
 Perform OR-assign operation on every bit of both BitSpans. More...
 
template<typename BitVectorType = AlignedBitVector>
BitSpanoperator^= (const BitVectorType &other)
 Perform XOR-assign operation on every bit of BitSpan and BitVector. More...
 
BitSpanoperator^= (const BitSpan &other)
 Perform XOR-assign operation on every bit of both BitSpans. More...
 
bool Get (const std::size_t position) const
 Get bit at given position. More...
 
bool operator[] (const std::size_t position) const
 Get bit at given position in the BitSpan. More...
 
void Set (const bool value)
 Sets all bits to value. More...
 
void Set (const bool value, const std::size_t position)
 Sets bit at postion to value. More...
 
const std::byte * GetData () const noexcept
 Get const reference to content of BitSpan. More...
 
std::byte * GetMutableData () noexcept
 Get reference to content of BitSpan. More...
 
std::size_t GetSize () const noexcept
 Get size of BitSpan. More...
 
std::string AsString () const noexcept
 Returns a string representation of this BitVector. More...
 
bool IsAligned () const noexcept
 Returns true if Allocator is aligned allocator. More...
 
template<typename BitVectorType >
void Copy (const std::size_t dest_from, const std::size_t dest_to, BitVectorType &other)
 copies the first (dest_to - dest_from) bits from other to the bits [dest_from, dest_to) in this. More...
 
template<typename BitVectorType >
void Copy (const std::size_t dest_from, BitVectorType &other)
 copies other to this[dest_from...dest_from+GetSize()]. More...
 
void Copy (const std::size_t dest_from, const std::size_t dest_to, BitSpan &other)
 copies the first (dest_to - dest_from) bits from other to the bits [dest_from, dest_to) in this. More...
 
void Copy (const std::size_t dest_from, const std::size_t dest_to, BitSpan &&other)
 copies the first (dest_to - dest_from) bits from other to the bits [dest_from, dest_to) in this. More...
 
void Copy (const std::size_t dest_from, BitSpan &other)
 copies other to this[dest_from...dest_from+GetSize()]. More...
 
void Copy (const std::size_t dest_from, BitSpan &&other)
 copies other to this[dest_from...dest_from+GetSize()]. More...
 

Detailed Description

Non-owning non-resizeable BitVector.

Provides a read-write BitVector API over a raw buffer, e.g. std::byte *. The underlying buffer is not owned by the BitSpan, in contrast to BitVector. Assumes that the buffer starts at the leftmost bit of the underlying buffer.

Constructor & Destructor Documentation

◆ BitSpan() [1/6]

encrypto::motion::BitSpan::BitSpan ( )
default

◆ ~BitSpan()

encrypto::motion::BitSpan::~BitSpan ( )
default

◆ BitSpan() [2/6]

encrypto::motion::BitSpan::BitSpan ( const BitSpan other)

◆ BitSpan() [3/6]

encrypto::motion::BitSpan::BitSpan ( BitSpan &&  other)

◆ BitSpan() [4/6]

template<typename BitVectorType >
encrypto::motion::BitSpan::BitSpan ( BitVectorType &  bit_vector)
inline

Construct a BitSpan from a BitVector.

Parameters
bit_vector

◆ BitSpan() [5/6]

encrypto::motion::BitSpan::BitSpan ( std::byte *  buffer,
std::size_t  bit_size,
bool  aligned = false 
)

Construct a BitSpan from std::byte buffer of length bit_size.

Parameters
buffer
bit_size
alignedAlignment of the buffer

◆ BitSpan() [6/6]

template<typename T >
encrypto::motion::BitSpan::BitSpan ( T *  buffer,
std::size_t  bit_size,
bool  aligned = false 
)
inline

Construct a BitSpan from a buffer of length bit_size.

Parameters
buffer
bit_size
alignedAlignment of the buffer

Member Function Documentation

◆ As()

template<typename BitVectorType = AlignedBitVector>
BitVectorType encrypto::motion::BitSpan::As ( ) const
inline

Converts this BitSpan to a BitVector.

Template Parameters
BitVectorTypeThe concrete type of the BitVector

◆ AsString()

std::string encrypto::motion::BitSpan::AsString ( ) const
noexcept

Returns a string representation of this BitVector.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Copy() [1/6]

void encrypto::motion::BitSpan::Copy ( const std::size_t  dest_from,
BitSpan &&  other 
)

copies other to this[dest_from...dest_from+GetSize()].

Exceptions
anstd::out_of_range exception if this is smaller than other.
Here is the call graph for this function:

◆ Copy() [2/6]

void encrypto::motion::BitSpan::Copy ( const std::size_t  dest_from,
BitSpan other 
)

copies other to this[dest_from...dest_from+GetSize()].

Exceptions
anstd::out_of_range exception if this is smaller than other.
Here is the call graph for this function:

◆ Copy() [3/6]

template<typename BitVectorType >
void encrypto::motion::BitSpan::Copy ( const std::size_t  dest_from,
BitVectorType &  other 
)

copies other to this[dest_from...dest_from+GetSize()].

Exceptions
anstd::out_of_range exception if this is smaller than other.
Here is the call graph for this function:

◆ Copy() [4/6]

void encrypto::motion::BitSpan::Copy ( const std::size_t  dest_from,
const std::size_t  dest_to,
BitSpan &&  other 
)

copies the first (dest_to - dest_from) bits from other to the bits [dest_from, dest_to) in this.

Exceptions
anstd::out_of_range exception if accessing invalid positions in this or other.
Here is the call graph for this function:

◆ Copy() [5/6]

void encrypto::motion::BitSpan::Copy ( const std::size_t  dest_from,
const std::size_t  dest_to,
BitSpan other 
)

copies the first (dest_to - dest_from) bits from other to the bits [dest_from, dest_to) in this.

Exceptions
anstd::out_of_range exception if accessing invalid positions in this or other.
Here is the call graph for this function:

◆ Copy() [6/6]

template<typename BitVectorType >
void encrypto::motion::BitSpan::Copy ( const std::size_t  dest_from,
const std::size_t  dest_to,
BitVectorType &  other 
)

copies the first (dest_to - dest_from) bits from other to the bits [dest_from, dest_to) in this.

Exceptions
anstd::out_of_range exception if accessing invalid positions in this or other.
Here is the call graph for this function:

◆ Empty()

bool encrypto::motion::BitSpan::Empty ( ) const
inlinenoexcept

Check if BitSpan is empty.

◆ Get()

bool encrypto::motion::BitSpan::Get ( const std::size_t  position) const

Get bit at given position.

Parameters
position
Here is the call graph for this function:

◆ GetData()

const std::byte* encrypto::motion::BitSpan::GetData ( ) const
inlinenoexcept

Get const reference to content of BitSpan.

Here is the caller graph for this function:

◆ GetMutableData()

std::byte* encrypto::motion::BitSpan::GetMutableData ( )
inlinenoexcept

Get reference to content of BitSpan.

Here is the caller graph for this function:

◆ GetSize()

std::size_t encrypto::motion::BitSpan::GetSize ( ) const
inlinenoexcept

Get size of BitSpan.

Here is the caller graph for this function:

◆ Invert()

void encrypto::motion::BitSpan::Invert ( )

In-place bit-wise invert.

Here is the call graph for this function:

◆ IsAligned()

bool encrypto::motion::BitSpan::IsAligned ( ) const
inlinenoexcept

Returns true if Allocator is aligned allocator.

◆ operator&() [1/2]

template<typename BitVectorType >
template BitVector< AlignedAllocator > encrypto::motion::BitSpan::operator& ( const BitSpan other) const

Perform AND operation on every bit of both BitSpans.

Parameters
other
Here is the call graph for this function:

◆ operator&() [2/2]

template<typename BitVectorType >
BitVectorType encrypto::motion::BitSpan::operator& ( const BitVectorType &  other) const

Perform AND operation on every bit of BitSpan and BitVector.

Parameters
other
Here is the call graph for this function:

◆ operator&=() [1/2]

BitSpan & encrypto::motion::BitSpan::operator&= ( const BitSpan other)

Perform AND-assign operation on every bit of both BitSpans.

Parameters
other
Here is the call graph for this function:

◆ operator&=() [2/2]

template<typename BitVectorType >
BitSpan & encrypto::motion::BitSpan::operator&= ( const BitVectorType &  other)

Perform AND-assign operation on every bit of BitSpan and BitVector.

Parameters
other
Here is the call graph for this function:

◆ operator=() [1/3]

BitSpan & encrypto::motion::BitSpan::operator= ( BitSpan &&  other)

◆ operator=() [2/3]

template<typename BitVectorType >
BitSpan& encrypto::motion::BitSpan::operator= ( BitVectorType &  bit_vector)
inline

Assignment from BitVector.

Parameters
bit_vectpr
Here is the call graph for this function:

◆ operator=() [3/3]

BitSpan & encrypto::motion::BitSpan::operator= ( const BitSpan other)

◆ operator==() [1/2]

bool encrypto::motion::BitSpan::operator== ( const BitSpan other) const

Compare the content with another BitSpan for equality.

Parameters
other
Here is the call graph for this function:

◆ operator==() [2/2]

template<typename BitVectorType >
bool encrypto::motion::BitSpan::operator== ( const BitVectorType &  other) const

Compare the content of a BitVectorType for equality.

Template Parameters
BitVectorType
Parameters
other
Here is the call graph for this function:

◆ operator[]()

bool encrypto::motion::BitSpan::operator[] ( const std::size_t  position) const
inline

Get bit at given position in the BitSpan.

Parameters
position
Here is the call graph for this function:

◆ operator^() [1/2]

template<typename BitVectorType >
template BitVector< AlignedAllocator > encrypto::motion::BitSpan::operator^ ( const BitSpan other) const

Perform XOR operation on every bit of both BitSpans.

Parameters
other
Here is the call graph for this function:

◆ operator^() [2/2]

template<typename BitVectorType >
BitVectorType encrypto::motion::BitSpan::operator^ ( const BitVectorType &  other) const

Perform XOR operation on every bit of BitSpan and BitVector.

Parameters
other
Here is the call graph for this function:

◆ operator^=() [1/2]

BitSpan & encrypto::motion::BitSpan::operator^= ( const BitSpan other)

Perform XOR-assign operation on every bit of both BitSpans.

Parameters
other
Here is the call graph for this function:

◆ operator^=() [2/2]

template<typename BitVectorType >
BitSpan & encrypto::motion::BitSpan::operator^= ( const BitVectorType &  other)

Perform XOR-assign operation on every bit of BitSpan and BitVector.

Parameters
other
Here is the call graph for this function:

◆ operator|() [1/2]

template<typename BitVectorType >
template BitVector< AlignedAllocator > encrypto::motion::BitSpan::operator| ( const BitSpan other) const

Perform OR operation on every bit of both BitSpans.

Parameters
other
Here is the call graph for this function:

◆ operator|() [2/2]

template<typename BitVectorType >
BitVectorType encrypto::motion::BitSpan::operator| ( const BitVectorType &  other) const

Perform OR operation on every bit of BitSpan and BitVector.

Parameters
other
Here is the call graph for this function:

◆ operator|=() [1/2]

BitSpan & encrypto::motion::BitSpan::operator|= ( const BitSpan other)

Perform OR-assign operation on every bit of both BitSpans.

Parameters
other
Here is the call graph for this function:

◆ operator|=() [2/2]

template<typename BitVectorType >
BitSpan & encrypto::motion::BitSpan::operator|= ( const BitVectorType &  other)

Perform OR-assign operation on every bit of BitSpan and BitVector.

Parameters
other
Here is the call graph for this function:

◆ operator~()

template<typename BitVectorType = AlignedBitVector>
BitVectorType encrypto::motion::BitSpan::operator~ ( ) const
inline

Return a BitVector containing bit-inverted values of this BitSpan.

◆ Set() [1/2]

void encrypto::motion::BitSpan::Set ( const bool  value)

Sets all bits to value.

Parameters
value
Here is the call graph for this function:

◆ Set() [2/2]

void encrypto::motion::BitSpan::Set ( const bool  value,
const std::size_t  position 
)

Sets bit at postion to value.

Parameters
value
position
Here is the call graph for this function:

◆ Subset()

template<typename BitVectorType >
template BitVector< AlignedAllocator > encrypto::motion::BitSpan::Subset ( const std::size_t  from,
const std::size_t  to 
) const

Returns a new BitVector containing the bits of this BitSpan between positions from and to.

Parameters
from
Here is the call graph for this function:
Here is the caller graph for this function:

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