BitMagic-C++
bm::basic_bmatrix< BV > Class Template Reference

Basic dense bit-matrix class. More...

#include <bmbmatrix.h>

Inheritance diagram for bm::basic_bmatrix< BV >:
Collaboration diagram for bm::basic_bmatrix< BV >:

Public Types

typedef BV bvector_type
 
typedef bvector_typebvector_type_ptr
 
typedef const bvector_typebvector_type_const_ptr
 
typedef BV::allocator_type allocator_type
 
typedef bvector_type::allocation_policy allocation_policy_type
 
typedef allocator_type::allocator_pool_type allocator_pool_type
 
typedef bvector_type::size_type size_type
 
typedef bvector_type::block_idx_type block_idx_type
 
typedef unsigned char octet_type
 

Public Member Functions

Construction, assignment


 basic_bmatrix (size_type rsize, allocation_policy_type ap=allocation_policy_type(), size_type bv_max_size=bm::id_max, const allocator_type &alloc=allocator_type())
 
 ~basic_bmatrix () BMNOEXCEPT
 
 basic_bmatrix (const basic_bmatrix< BV > &bbm)
 
basic_bmatrix< BV > & operator= (const basic_bmatrix< BV > &bbm)
 
 basic_bmatrix (basic_bmatrix< BV > &&bbm) BMNOEXCEPT
 
basic_bmatrix< BV > & operator= (basic_bmatrix< BV > &&bbm) BMNOEXCEPT
 
void set_allocator_pool (allocator_pool_type *pool_ptr) BMNOEXCEPT
 
content manipulation


void swap (basic_bmatrix< BV > &bbm) BMNOEXCEPT
 
void copy_from (const basic_bmatrix< BV > &bbm)
 
row access


const bvector_typerow (size_type i) const BMNOEXCEPT
 
bvector_type_const_ptr get_row (size_type i) const BMNOEXCEPT
 
bvector_typeget_row (size_type i) BMNOEXCEPT
 
size_type rows () const BMNOEXCEPT
 
bvector_type_ptr construct_row (size_type row)
 
bvector_type_ptr construct_row (size_type row, const bvector_type &bv)
 
void destruct_row (size_type row)
 
octet access and transposition


void set_octet (size_type pos, size_type octet_idx, unsigned char octet)
 
void insert_octet (size_type pos, size_type octet_idx, unsigned char octet)
 
unsigned char get_octet (size_type pos, size_type octet_idx) const BMNOEXCEPT
 
int compare_octet (size_type pos, size_type octet_idx, char octet) const BMNOEXCEPT
 
Utility function


bool test_4rows (unsigned i) const BMNOEXCEPT
 Test if 4 rows from i are not NULL.
 
const bm::word_tget_block (size_type p, unsigned i, unsigned j) const BMNOEXCEPT
 Get low level internal access to.
 
unsigned get_half_octet (size_type pos, size_type row_idx) const BMNOEXCEPT
 
void optimize (bm::word_t *temp_block=0, typename bvector_type::optmode opt_mode=bvector_type::opt_compress, typename bvector_type::statistics *stat=0)
 run memory optimization for all bit-vector rows
 
void optimize_block (block_idx_type nb)
 

Protected Member Functions

void allocate_rows (size_type rsize)
 
void free_rows () BMNOEXCEPT
 
bvector_typeconstruct_bvector (const bvector_type *bv) const
 
void destruct_bvector (bvector_type *bv) const
 

Static Protected Member Functions

static void throw_bad_alloc ()
 

Protected Attributes

size_type bv_size_
 
allocator_type alloc_
 
allocation_policy_type ap_
 
allocator_pool_typepool_
 
bvector_type_ptrbv_rows_
 
size_type rsize_
 

Detailed Description

template<typename BV>
class bm::basic_bmatrix< BV >

Basic dense bit-matrix class.

Container of row-major bit-vectors, forming a bit-matrix. This class uses dense form of row storage. It is applicable as a build block for other sparse containers and succinct data structures, implementing high level abstractions.

Definition at line 53 of file bmbmatrix.h.

Member Typedef Documentation

◆ allocation_policy_type

template<typename BV >
bvector_type::allocation_policy bm::basic_bmatrix< BV >::allocation_policy_type

Definition at line 60 of file bmbmatrix.h.

◆ allocator_pool_type

template<typename BV >
allocator_type::allocator_pool_type bm::basic_bmatrix< BV >::allocator_pool_type

Definition at line 61 of file bmbmatrix.h.

◆ allocator_type

template<typename BV >
BV::allocator_type bm::basic_bmatrix< BV >::allocator_type

Definition at line 59 of file bmbmatrix.h.

◆ block_idx_type

template<typename BV >
bvector_type::block_idx_type bm::basic_bmatrix< BV >::block_idx_type

Definition at line 63 of file bmbmatrix.h.

◆ bvector_type

template<typename BV >
BV bm::basic_bmatrix< BV >::bvector_type

Definition at line 56 of file bmbmatrix.h.

◆ bvector_type_const_ptr

template<typename BV >
const bvector_type* bm::basic_bmatrix< BV >::bvector_type_const_ptr

Definition at line 58 of file bmbmatrix.h.

◆ bvector_type_ptr

template<typename BV >
bvector_type* bm::basic_bmatrix< BV >::bvector_type_ptr

Definition at line 57 of file bmbmatrix.h.

◆ octet_type

template<typename BV >
unsigned char bm::basic_bmatrix< BV >::octet_type

Definition at line 64 of file bmbmatrix.h.

◆ size_type

template<typename BV >
bvector_type::size_type bm::basic_bmatrix< BV >::size_type

Definition at line 62 of file bmbmatrix.h.

Constructor & Destructor Documentation

◆ basic_bmatrix() [1/3]

template<typename BV >
bm::basic_bmatrix< BV >::basic_bmatrix ( size_type rsize,
allocation_policy_type ap = allocation_policy_type(),
size_type bv_max_size = bm::id_max,
const allocator_type & alloc = allocator_type() )

Definition at line 506 of file bmbmatrix.h.

References bm::basic_bmatrix< BV >::allocate_rows().

◆ ~basic_bmatrix()

template<typename BV >
bm::basic_bmatrix< BV >::~basic_bmatrix ( )

Definition at line 523 of file bmbmatrix.h.

◆ basic_bmatrix() [2/3]

template<typename BV >
bm::basic_bmatrix< BV >::basic_bmatrix ( const basic_bmatrix< BV > & bbm)

copy-ctor

Definition at line 531 of file bmbmatrix.h.

References bm::basic_bmatrix< BV >::copy_from().

◆ basic_bmatrix() [3/3]

template<typename BV >
bm::basic_bmatrix< BV >::basic_bmatrix ( basic_bmatrix< BV > && bbm)

move-ctor

Definition at line 545 of file bmbmatrix.h.

Member Function Documentation

◆ allocate_rows()

template<typename BV >
void bm::basic_bmatrix< BV >::allocate_rows ( size_type rsize)
protected

Definition at line 643 of file bmbmatrix.h.

References BM_ASSERT.

Referenced by bm::basic_bmatrix< BV >::basic_bmatrix().

◆ compare_octet()

template<typename BV >
int bm::basic_bmatrix< BV >::compare_octet ( size_type pos,
size_type octet_idx,
char octet ) const

Compare vector[pos] with octet

It uses regulat comparison of chars to comply with the (signed) char sort order.

Parameters
pos- column position in the matrix
octet_idx- octet based row position (1 octet - 8 rows)
octet- octet value to compare
Returns
0 - equal, -1 - less(vect[pos] < octet), 1 - greater

Definition at line 1012 of file bmbmatrix.h.

◆ construct_bvector()

template<typename BV >
basic_bmatrix< BV >::bvector_type * bm::basic_bmatrix< BV >::construct_bvector ( const bvector_type * bv) const
protected

Definition at line 765 of file bmbmatrix.h.

◆ construct_row() [1/2]

template<typename BV >
basic_bmatrix< BV >::bvector_type_ptr bm::basic_bmatrix< BV >::construct_row ( size_type row)

Make sure row is constructed, return bit-vector

Definition at line 715 of file bmbmatrix.h.

References BM_ASSERT, and construct_bvector().

Referenced by bm::base_sparse_vector< Val, BV, MAX_SIZE >::base_sparse_vector(), and bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::import_no_check().

◆ construct_row() [2/2]

template<typename BV >
basic_bmatrix< BV >::bvector_type_ptr bm::basic_bmatrix< BV >::construct_row ( size_type row,
const bvector_type & bv )

Make sure row is copy-constructed, return bit-vector

Definition at line 730 of file bmbmatrix.h.

References BM_ASSERT, and construct_bvector().

◆ copy_from()

◆ destruct_bvector()

template<typename BV >
void bm::basic_bmatrix< BV >::destruct_bvector ( bvector_type * bv) const
protected

Definition at line 790 of file bmbmatrix.h.

◆ destruct_row()

template<typename BV >
void bm::basic_bmatrix< BV >::destruct_row ( size_type row)

Definition at line 749 of file bmbmatrix.h.

References BM_ASSERT.

Referenced by bm::base_sparse_vector< Val, BV, MAX_SIZE >::free_plain().

◆ free_rows()

template<typename BV >
void bm::basic_bmatrix< BV >::free_rows ( )
protected

Definition at line 664 of file bmbmatrix.h.

Referenced by bm::basic_bmatrix< BV >::operator=().

◆ get_block()

template<typename BV >
const bm::word_t * bm::basic_bmatrix< BV >::get_block ( size_type p,
unsigned i,
unsigned j ) const

Get low level internal access to.

Definition at line 804 of file bmbmatrix.h.

◆ get_half_octet()

template<typename BV >
unsigned bm::basic_bmatrix< BV >::get_half_octet ( size_type pos,
size_type row_idx ) const

◆ get_octet()

template<typename BV >
unsigned char bm::basic_bmatrix< BV >::get_octet ( size_type pos,
size_type octet_idx ) const

return octet from the matrix

Parameters
pos- column position in the matrix
octet_idx- octet based row position (1 octet - 8 rows)

Definition at line 913 of file bmbmatrix.h.

References BM_IS_GAP, BMGAP_PTR, FULL_BLOCK_FAKE_ADDR, bm::gap_test_unr(), bm::set_array_mask, bm::set_array_shift, bm::set_block_mask, bm::set_block_shift, bm::set_word_mask, and bm::set_word_shift.

Referenced by bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::get().

◆ get_row() [1/2]

template<typename BV >
basic_bmatrix< BV >::bvector_type * bm::basic_bmatrix< BV >::get_row ( size_type i)

Get row bit-vector. Can return NULL

Definition at line 580 of file bmbmatrix.h.

References BM_ASSERT.

◆ get_row() [2/2]

◆ insert_octet()

template<typename BV >
void bm::basic_bmatrix< BV >::insert_octet ( size_type pos,
size_type octet_idx,
unsigned char octet )

Bit-transpose and insert an octet and assign it to a bit-matrix

Parameters
pos- column position in the matrix
octet_idx- octet based row position (1 octet - 8 rows)
octet- value to assign

Definition at line 864 of file bmbmatrix.h.

References BM_ASSERT.

◆ operator=() [1/2]

template<typename BV >
basic_bmatrix< BV > & bm::basic_bmatrix< BV >::operator= ( basic_bmatrix< BV > && bbm)
inline

move assignmment operator

Definition at line 90 of file bmbmatrix.h.

References bm::basic_bmatrix< BV >::free_rows(), and bm::basic_bmatrix< BV >::swap().

◆ operator=() [2/2]

template<typename BV >
basic_bmatrix< BV > & bm::basic_bmatrix< BV >::operator= ( const basic_bmatrix< BV > & bbm)
inline

Definition at line 79 of file bmbmatrix.h.

References bm::basic_bmatrix< BV >::copy_from().

◆ optimize()

template<typename BV >
void bm::basic_bmatrix< BV >::optimize ( bm::word_t * temp_block = 0,
typename bvector_type::optmode opt_mode = bvector_type::opt_compress,
typename bvector_type::statistics * stat = 0 )

run memory optimization for all bit-vector rows

Parameters
temp_block- pre-allocated memory block to avoid re-allocs
opt_mode- requested compression depth
stat- memory allocation statistics after optimization

Definition at line 1082 of file bmbmatrix.h.

References bm::bv_statistics::add(), BM_DECLARE_TEMP_BLOCK, and bm::bv_statistics::reset().

◆ optimize_block()

template<typename BV >
void bm::basic_bmatrix< BV >::optimize_block ( block_idx_type nb)

Optimize block in all planes

Definition at line 1112 of file bmbmatrix.h.

References bm::get_block_coord().

Referenced by bm::base_sparse_vector< Val, BV, MAX_SIZE >::optimize_block().

◆ row()

◆ rows()

template<typename BV >
size_type bm::basic_bmatrix< BV >::rows ( ) const
inline

get number of value rows

Definition at line 132 of file bmbmatrix.h.

References bm::basic_bmatrix< BV >::rsize_.

◆ set_allocator_pool()

template<typename BV >
void bm::basic_bmatrix< BV >::set_allocator_pool ( allocator_pool_type * pool_ptr)
inline

Definition at line 101 of file bmbmatrix.h.

References bm::basic_bmatrix< BV >::pool_.

◆ set_octet()

template<typename BV >
void bm::basic_bmatrix< BV >::set_octet ( size_type pos,
size_type octet_idx,
unsigned char octet )

Bit-transpose an octet and assign it to a bit-matrix

Parameters
pos- column position in the matrix
octet_idx- octet based row position (1 octet - 8 rows)
octet- value to assign

Definition at line 821 of file bmbmatrix.h.

References BM_ASSERT.

Referenced by bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::assign().

◆ swap()

template<typename BV >
void bm::basic_bmatrix< BV >::swap ( basic_bmatrix< BV > & bbm)

◆ test_4rows()

template<typename BV >
bool bm::basic_bmatrix< BV >::test_4rows ( unsigned i) const

Test if 4 rows from i are not NULL.

Definition at line 589 of file bmbmatrix.h.

References BM_ASSERT.

◆ throw_bad_alloc()

template<typename BV >
static void bm::basic_bmatrix< BV >::throw_bad_alloc ( )
inlinestaticprotected

Definition at line 233 of file bmbmatrix.h.

Field Documentation

◆ alloc_

template<typename BV >
allocator_type bm::basic_bmatrix< BV >::alloc_
protected

Definition at line 238 of file bmbmatrix.h.

Referenced by bm::basic_bmatrix< BV >::copy_from().

◆ ap_

template<typename BV >
allocation_policy_type bm::basic_bmatrix< BV >::ap_
protected

Definition at line 239 of file bmbmatrix.h.

Referenced by bm::basic_bmatrix< BV >::copy_from().

◆ bv_rows_

template<typename BV >
bvector_type_ptr* bm::basic_bmatrix< BV >::bv_rows_
protected

Definition at line 242 of file bmbmatrix.h.

Referenced by bm::basic_bmatrix< BV >::copy_from().

◆ bv_size_

template<typename BV >
size_type bm::basic_bmatrix< BV >::bv_size_
protected

Definition at line 237 of file bmbmatrix.h.

Referenced by bm::basic_bmatrix< BV >::copy_from().

◆ pool_

template<typename BV >
allocator_pool_type* bm::basic_bmatrix< BV >::pool_
protected

Definition at line 240 of file bmbmatrix.h.

Referenced by bm::basic_bmatrix< BV >::set_allocator_pool().

◆ rsize_

template<typename BV >
size_type bm::basic_bmatrix< BV >::rsize_
protected

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