pasta::bit_vector  v1.0.0
Compact and Fast Rank and Select Data Structure for Bit Vectors
pasta::BitAccess Class Reference

Utility class used for the access operator of the BitVector. More...

#include <bit_vector.hpp>

Public Member Functions

 BitAccess ()=delete
 Deleted constructor.
 
 BitAccess (BitAccess &&)=delete
 Avoiding implicit generation of the move constructor.
 
BitAccessoperator= (BitAccess const &)=delete
 Avoiding implicit copy assignment.
 
BitAccessoperator= (BitAccess &&)=delete
 Avoiding implicit move assignment.
 
 BitAccess (uint64_t *const data, size_t const position) noexcept
 Constructor setting 64-bit word and position of the bit in the word. More...
 
 operator bool () const noexcept
 User-defined conversion function to bool. More...
 
BitAccessoperator= (bool const value) noexcept
 Assignment operator to set a bit within the bit vector. More...
 
int64_t distance (BitAccess const &other) const noexcept
 Computes the distance to another BitAccess instance. More...
 

Friends

class BitVector
 Forward declaration.
 
bool operator== (BitAccess const &a, BitAccess const &b) noexcept
 Comparison of two BitAccess instances for equality. More...
 
bool operator!= (BitAccess const &a, BitAccess const &b) noexcept
 Comparison of two BitAccess instances for inequality. More...
 

Detailed Description

Utility class used for the access operator of the BitVector.

This utility class is created when the bit vector is accessed through the access operator. It cannot be created explicitly and cannot be assigned. It can only be cast to bool (for read access) or be assigned a bool (for write access).

Constructor & Destructor Documentation

◆ BitAccess()

pasta::BitAccess::BitAccess ( uint64_t *const  data,
size_t const  position 
)
inlinenoexcept

Constructor setting 64-bit word and position of the bit in the word.

This constructor can be used when a single bit in the bit vector has to be accessed and one does not want to extract the bit from the 64-bit word manually.

Parameters
dataPointer to the 64-bit word that contains the bit.
positionPosition of the bit within the 64-bit word.

Member Function Documentation

◆ distance()

int64_t pasta::BitAccess::distance ( BitAccess const &  other) const
inlinenoexcept

Computes the distance to another BitAccess instance.

This function is only used within the iterator and usually should not be required in any other situation. It has undefined behavior if used for two instances from different BitVector.

Parameters
otherThe BitAccess instance the distance is computed to.
Returns
The distance between this and the other BitAccess instance.

◆ operator bool()

pasta::BitAccess::operator bool ( ) const
inlinenoexcept

User-defined conversion function to bool.

Used for read access to a single bit.

◆ operator=()

BitAccess & pasta::BitAccess::operator= ( bool const  value)
inlinenoexcept

Assignment operator to set a bit within the bit vector.

Parameters
valueValue the bit should be written to.
Returns
This after the bit has been written.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( BitAccess const &  a,
BitAccess const &  b 
)
friend

Comparison of two BitAccess instances for inequality.

This does not compare the value the BitAccess instance refers to but rather if the two instances refer to different position or to different BitVector.

Parameters
aFirst BitAccess instance.
bSecond BitAccess instance.
Returns
true if both instances refer to different position or different BitVector and false otherwise.

◆ operator==

bool operator== ( BitAccess const &  a,
BitAccess const &  b 
)
friend

Comparison of two BitAccess instances for equality.

This does not compare the value the BitAccess instance refers to but rather if the two instances refer to the same position in the same BitVector.

Parameters
aFirst BitAccess instance.
bSecond BitAccess instance.
Returns
true if both instances refer to the same position in the same BitVector and false otherwise.

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