HSDS
 All Data Structures Namespaces Files Functions Variables Typedefs Friends Macros
Public Member Functions | Static Public Member Functions
hsds::BitVector Class Reference

Succinct bit vector class. More...

#include <bit-vector.hpp>

Public Member Functions

 BitVector (uint64_t size)
 Constructor. More...
 
virtual ~BitVector ()
 Destructor. More...
 
void clear ()
 Clear bit vector. More...
 
bool operator[] (uint64_t i) const
 Get value from bit vector by index. More...
 
void set (uint64_t i, bool b=true)
 Set value to bit vector by index. More...
 
void push_back (bool b)
 push bit to bit vector More...
 
void push_back_bits (uint64_t x, uint64_t len)
 push bits to bit vector More...
 
uint64_t get_bits (uint64_t pos, uint64_t len) const
 get bits from bit vector More...
 
void build (bool enable_faster_select1=false, bool enable_faster_select0=false)
 Build succinct bit vector. More...
 
FORCE_INLINE uint64_t size () const
 Returns number of the element in bit vector. More...
 
FORCE_INLINE uint64_t size (bool b) const
 Returns the number of bits that matches with argument in the bit vector. More...
 
FORCE_INLINE bool empty () const
 Returns whether the vector is empty (i.e. More...
 
FORCE_INLINE uint64_t rank (uint64_t i, bool b=true) const
 Returns Number of the bits equal to b up to position i More...
 
uint64_t rank0 (uint64_t i) const
 Returns Number of the bits equal to 0 up to position i More...
 
uint64_t rank1 (uint64_t i) const
 Returns Number of the bits equal to 1 up to position i More...
 
FORCE_INLINE uint64_t select (uint64_t x, bool b=true) const
 Returns the position of the x-th occurrence of b More...
 
uint64_t select0 (uint64_t x) const
 Returns the position of the x-th occurrence of 0. More...
 
uint64_t select1 (uint64_t x) const
 Returns the position of the x-th occurrence of 1. More...
 
void save (std::ostream &os) const throw (hsds::Exception)
 Save bit vector to the ostream. More...
 
void load (std::istream &is) throw (hsds::Exception)
 Load bit vector from istream. More...
 
uint64_t map (void *ptr, uint64_t size) throw (hsds::Exception)
 Mapping pointer to BitVector. More...
 
void swap (BitVector &x)
 Exchanges the content of the instance. More...
 

Static Public Member Functions

 BitVector ()
 Constructor. More...
 

Detailed Description

Succinct bit vector class.

Definition at line 53 of file bit-vector.hpp.

Constructor & Destructor Documentation

hsds::BitVector::BitVector ( )
static

Constructor.

hsds::BitVector::BitVector ( uint64_t  size)

Constructor.

Parameters
[in]sizeSize of bit vector
virtual hsds::BitVector::~BitVector ( )
virtual

Destructor.

Member Function Documentation

void hsds::BitVector::build ( bool  enable_faster_select1 = false,
bool  enable_faster_select0 = false 
)

Build succinct bit vector.

Parameters
[in]enable_faster_select1Enable faster select1().
[in]enable_faster_select0Enable faster select0().
void hsds::BitVector::clear ( )
inline

Clear bit vector.

Definition at line 76 of file bit-vector.hpp.

FORCE_INLINE bool hsds::BitVector::empty ( ) const
inline

Returns whether the vector is empty (i.e.

whether its size is 0)

Return values
trueContainer size equals 0.
falseContainer size not equals 0.

Definition at line 157 of file bit-vector.hpp.

uint64_t hsds::BitVector::get_bits ( uint64_t  pos,
uint64_t  len 
) const

get bits from bit vector

Parameters
[in]posposition of bits
[in]lenbit length
Returns
bits
void hsds::BitVector::load ( std::istream &  is) throw (hsds::Exception)

Load bit vector from istream.

Parameters
[in]isThe instance of std::istream
Exceptions
hsds::ExceptionWhen failed to load.
uint64_t hsds::BitVector::map ( void *  ptr,
uint64_t  size 
) throw (hsds::Exception)

Mapping pointer to BitVector.

Parameters
[in]ptrPointer of the mmaped file
[in]sizeSize of mmaped file
Returns
Actually mapped size(byte size of offset from ptr).
Exceptions
hsds::ExceptionWhen failed to load.
bool hsds::BitVector::operator[] ( uint64_t  i) const

Get value from bit vector by index.

Parameters
[in]iIndex of bit vector
Returns
The value of the specified index
void hsds::BitVector::push_back ( bool  b)

push bit to bit vector

Parameters
[in]bBoolean value that indicates the bit to push.(true = 1, false = 0)
void hsds::BitVector::push_back_bits ( uint64_t  x,
uint64_t  len 
)

push bits to bit vector

Parameters
[in]xbits
[in]lenbit length
FORCE_INLINE uint64_t hsds::BitVector::rank ( uint64_t  i,
bool  b = true 
) const
inline

Returns Number of the bits equal to b up to position i

Parameters
[in]iIndex of the bit vector
[in]bBoolean value that indicates bit type.(true = 1, false = 0)
Returns
Number of the bits

Definition at line 169 of file bit-vector.hpp.

uint64_t hsds::BitVector::rank0 ( uint64_t  i) const

Returns Number of the bits equal to 0 up to position i

Parameters
[in]iIndex of the bit vector
Returns
Number of the bits equal to 0
uint64_t hsds::BitVector::rank1 ( uint64_t  i) const

Returns Number of the bits equal to 1 up to position i

Parameters
[in]iIndex of the bit vector
Returns
Number of the bits equal to 1
void hsds::BitVector::save ( std::ostream &  os) const throw (hsds::Exception)

Save bit vector to the ostream.

Parameters
[out]osThe instance of std::ostream
Exceptions
hsds::ExceptionWhen failed to save.
FORCE_INLINE uint64_t hsds::BitVector::select ( uint64_t  x,
bool  b = true 
) const
inline

Returns the position of the x-th occurrence of b

Parameters
[in]xRank number of b-bits
[in]bBoolean value that indicates bit type.(true = 1, false = 0)
Returns
Index of x-th 0

Definition at line 199 of file bit-vector.hpp.

uint64_t hsds::BitVector::select0 ( uint64_t  x) const

Returns the position of the x-th occurrence of 0.

Parameters
[in]xRank number of 0-bits
Returns
Index of x-th 0
uint64_t hsds::BitVector::select1 ( uint64_t  x) const

Returns the position of the x-th occurrence of 1.

Parameters
[in]xRank number of 1-bits
Returns
Index of x-th 1
void hsds::BitVector::set ( uint64_t  i,
bool  b = true 
)

Set value to bit vector by index.

Parameters
[in]iIndex of bit vector
[in]bBoolean value that indicates the bit to set.(true = 1, false = 0)
FORCE_INLINE uint64_t hsds::BitVector::size ( ) const
inline

Returns number of the element in bit vector.

Returns
Size of the bit vector

Definition at line 136 of file bit-vector.hpp.

FORCE_INLINE uint64_t hsds::BitVector::size ( bool  b) const
inline

Returns the number of bits that matches with argument in the bit vector.

Parameters
[in]bBoolean value that indicates bit type.(true = 1, false = 0)
Returns
Number of bits that matches with argument in the bit vector

Definition at line 147 of file bit-vector.hpp.

void hsds::BitVector::swap ( BitVector x)

Exchanges the content of the instance.

Parameters
[in,out]xAnother BitVector instance

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