BitMagic-C++
|
Base class for bit-transposed(bit-sliced) sparse vector construction. More...
#include <bmbmatrix.h>
Public Types | |
enum | bit_planes { sv_slices = (sizeof(Val) * 8 * MAX_SIZE + 1) , sv_value_slices = (sizeof(Val) * 8 * MAX_SIZE) } |
enum | vector_capacity { max_vector_size = MAX_SIZE } |
typedef Val | value_type |
typedef BV | bvector_type |
typedef BV::size_type | size_type |
typedef bvector_type * | bvector_type_ptr |
typedef const bvector_type * | bvector_type_const_ptr |
typedef const value_type & | const_reference |
typedef BV::allocator_type | allocator_type |
typedef bvector_type::allocation_policy | allocation_policy_type |
typedef bvector_type::enumerator | bvector_enumerator_type |
typedef allocator_type::allocator_pool_type | allocator_pool_type |
typedef bm::basic_bmatrix< BV > | bmatrix_type |
typedef std::make_unsigned< value_type >::type | unsigned_value_type |
Public Member Functions | |
base_sparse_vector () | |
base_sparse_vector (bm::null_support null_able, allocation_policy_type ap=allocation_policy_type(), size_type bv_max_size=bm::id_max, const allocator_type &alloc=allocator_type()) | |
More... | |
base_sparse_vector (const base_sparse_vector< Val, BV, MAX_SIZE > &bsv) | |
base_sparse_vector (base_sparse_vector< Val, BV, MAX_SIZE > &&bsv) BMNOEXCEPT | |
More... | |
void | swap (base_sparse_vector< Val, BV, MAX_SIZE > &bsv) BMNOEXCEPT |
More... | |
size_type | size () const BMNOEXCEPT |
More... | |
void | resize (size_type new_size, bool set_null) |
void | clear_range (size_type left, size_type right, bool set_null) |
void | keep_range_no_check (size_type left, size_type right, bm::null_support slice_null) |
More... | |
void | clear_all (bool free_mem=true) BMNOEXCEPT |
resize to zero, free memory More... | |
bool | empty () const BMNOEXCEPT |
More... | |
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 More... | |
void | calc_stat (typename bvector_type::statistics *st) const BMNOEXCEPT |
Calculates memory statistics. More... | |
bool | equal (const base_sparse_vector< Val, BV, MAX_SIZE > &sv, bm::null_support null_able=bm::use_null) const BMNOEXCEPT |
check if another sparse vector has the same content and size More... | |
Protected Types | |
typedef bvector_type::block_idx_type | block_idx_type |
Protected Member Functions | |
void | copy_from (const base_sparse_vector< Val, BV, MAX_SIZE > &bsv) |
More... | |
void | merge_matr (bmatrix_type &bmatr) |
Merge plane bvectors from an outside base matrix Note: outside base matrix gets destroyed. More... | |
void | freeze_matr () |
Turn on RO mode. More... | |
void | clear_value_planes_from (unsigned plane_idx, size_type idx) |
More... | |
void | insert_clear_value_planes_from (unsigned plane_idx, size_type idx) |
More... | |
void | erase_column (size_type idx, bool erase_null) |
More... | |
void | insert_null (size_type idx, bool not_null) |
More... | |
void | bit_sub_rows (const bvector_type &bv, bool use_null) |
Set SUB (MINUS) operation on all existing bit-slices. More... | |
void | bit_and_rows (const bvector_type &bv) |
Set AND (intersect) operation on all existing bit-slices. More... | |
void | optimize_block (block_idx_type nb, typename BV::optmode opt_mode) |
plane index for the "NOT NULL" flags plane More... | |
void | copy_range_slices (const base_sparse_vector< Val, BV, MAX_SIZE > &bsv, typename base_sparse_vector< Val, BV, MAX_SIZE >::size_type left, typename base_sparse_vector< Val, BV, MAX_SIZE >::size_type right, bm::null_support slice_null) |
Perform copy_range() on a set of planes. More... | |
Static Protected Member Functions | |
static constexpr unsigned | value_bits () BMNOEXCEPT |
Number of total bit-planes in the value type. More... | |
Protected Attributes | |
bmatrix_type | bmatr_ |
bit-transposed matrix More... | |
unsigned_value_type | slice_mask_ = 0 |
slice presence bit-mask More... | |
size_type | size_ = 0 |
array size More... | |
unsigned | effective_slices_ =0 |
number of bit slices actually allocated More... | |
bool | is_ro_ =false |
read-only More... | |
Various traits <br> | |
bool | is_nullable () const BMNOEXCEPT |
check if container supports NULL(unassigned) values More... | |
bm::null_support | get_null_support () const BMNOEXCEPT |
check if container supports NULL (unassigned) values More... | |
const bvector_type * | get_null_bvector () const BMNOEXCEPT |
Get bit-vector of assigned values or NULL (if not constructed that way) More... | |
bool | is_null (size_type idx) const BMNOEXCEPT |
test if specified element is NULL More... | |
void | set_allocator_pool (allocator_pool_type *pool_ptr) BMNOEXCEPT |
Set allocation pool. More... | |
allocator_pool_type * | get_allocator_pool () const BMNOEXCEPT |
Get allocation pool. More... | |
static constexpr bool | is_signed () BMNOEXCEPT |
returns true if value type is signed integral type More... | |
Access to internals <br> | |
bvector_type_ptr | get_create_slice (unsigned i) |
get access to bit-plain, function checks and creates a plane More... | |
bvector_type_const_ptr | get_slice (unsigned i) const BMNOEXCEPT |
get read-only access to bit-plane More... | |
unsigned | effective_slices () const BMNOEXCEPT |
Number of effective bit-planes in the value type. More... | |
bvector_type_ptr | slice (unsigned i) BMNOEXCEPT |
get access to bit-plane as is (can return NULL) More... | |
bvector_type_const_ptr | slice (unsigned i) const BMNOEXCEPT |
More... | |
bvector_type * | get_null_bvect () BMNOEXCEPT |
More... | |
void | free_slice (unsigned i) |
free memory in bit-plane More... | |
bm::id64_t | get_slice_mask (unsigned element_idx) const BMNOEXCEPT |
More... | |
const bmatrix_type & | get_bmatrix () const BMNOEXCEPT |
More... | |
bmatrix_type & | get_bmatrix () BMNOEXCEPT |
access to internal bit-matrix More... | |
void | mark_null_idx (unsigned null_idx) BMNOEXCEPT |
Set NULL plain index. More... | |
static unsigned | slices () BMNOEXCEPT |
get total number of bit-planes in the vector More... | |
static unsigned | stored_slices () BMNOEXCEPT |
Number of stored bit-planes (value planes + extra. More... | |
static unsigned_value_type | s2u (value_type v) BMNOEXCEPT |
Convert signed value type to unsigned representation. More... | |
static value_type | u2s (unsigned_value_type v) BMNOEXCEPT |
Convert unsigned value type to signed representation. More... | |
Base class for bit-transposed(bit-sliced) sparse vector construction.
Keeps the basic housekeeping lements like matrix of sparse elements
Definition at line 335 of file bmbmatrix.h.
enum bm::base_sparse_vector::bit_planes |
Enumerator | |
---|---|
sv_slices | |
sv_value_slices |
Definition at line 338 of file bmbmatrix.h.
enum bm::base_sparse_vector::vector_capacity |
Enumerator | |
---|---|
max_vector_size |
Definition at line 344 of file bmbmatrix.h.
bm::base_sparse_vector< Val, BV, MAX_SIZE >::base_sparse_vector | ( | bm::null_support | null_able, |
allocation_policy_type | ap = allocation_policy_type() , |
||
size_type | bv_max_size = bm::id_max , |
||
const allocator_type & | alloc = allocator_type() |
||
) |
Definition at line 1513 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_, bm::basic_bmatrix< BV >::construct_row(), bm::basic_bmatrix< BV >::set_null_idx(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::slice_mask_, and bm::use_null.
|
inline |
move-ctor
Definition at line 374 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_, bm::base_sparse_vector< Val, BV, MAX_SIZE >::effective_slices_, bm::base_sparse_vector< Val, BV, MAX_SIZE >::size_, and bm::basic_bmatrix< BV >::swap().
|
inlineprotected |
Set AND (intersect) operation on all existing bit-slices.
bv | - argument vector row[i] -= bv |
Definition at line 651 of file bmbmatrix.h.
References bm::basic_bmatrix< BV >::bit_and_rows(), and bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_.
|
inlineprotected |
Set SUB (MINUS) operation on all existing bit-slices.
bv | - argument vector row[i] -= bv |
Definition at line 644 of file bmbmatrix.h.
References bm::basic_bmatrix< BV >::bit_sub_rows(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_, and bm::use_null.
void bm::base_sparse_vector< Val, BV, MAX_SIZE >::calc_stat | ( | typename bvector_type::statistics * | st | ) | const |
Calculates memory statistics.
Function fills statistics structure containing information about how this vector uses memory and estimation of max. amount of memory bvector needs to serialize itself.
st | - pointer on statistics structure to be filled in. |
Definition at line 1797 of file bmbmatrix.h.
References BM_ASSERT.
void bm::base_sparse_vector< Val, BV, MAX_SIZE >::clear_all | ( | bool | free_mem = true | ) |
resize to zero, free memory
free_mem | - fully destroys the plane vectors if true |
Definition at line 1639 of file bmbmatrix.h.
|
protected |
clear column in all value planes
plane_idx | - row (plane index to start from) |
idx | - bit (column) to clear |
Definition at line 1813 of file bmbmatrix.h.
|
protected |
Definition at line 1543 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_, bm::base_sparse_vector< Val, BV, MAX_SIZE >::effective_slices_, bm::base_sparse_vector< Val, BV, MAX_SIZE >::get_bmatrix(), bm::basic_bmatrix< BV >::get_null_idx(), bm::basic_bmatrix< BV >::row(), bm::basic_bmatrix< BV >::rows(), and bm::base_sparse_vector< Val, BV, MAX_SIZE >::size().
|
protected |
Perform copy_range() on a set of planes.
Definition at line 1909 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_, bm::base_sparse_vector< Val, BV, MAX_SIZE >::get_null_bvector(), bm::basic_bmatrix< BV >::row(), bm::basic_bmatrix< BV >::rows(), and bm::use_null.
|
inline |
Number of effective bit-planes in the value type.
Definition at line 493 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::effective_slices_.
|
inline |
return true if empty
Definition at line 400 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::size().
bool bm::base_sparse_vector< Val, BV, MAX_SIZE >::equal | ( | const base_sparse_vector< Val, BV, MAX_SIZE > & | sv, |
bm::null_support | null_able = bm::use_null |
||
) | const |
check if another sparse vector has the same content and size
sv | - sparse vector for comparison |
null_able | - flag to consider NULL vector in comparison (default) or compare only value content planes |
Definition at line 1840 of file bmbmatrix.h.
References BM_ASSERT, and bm::use_null.
|
protected |
erase bit (column) from all planes
idx | - bit (column) to erase |
erase_null | - erase the NULL vector |
Definition at line 1831 of file bmbmatrix.h.
|
inline |
free memory in bit-plane
Definition at line 515 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_, and bm::basic_bmatrix< BV >::destruct_row().
|
inlineprotected |
Turn on RO mode.
Definition at line 612 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_, bm::basic_bmatrix< BV >::freeze(), and bm::base_sparse_vector< Val, BV, MAX_SIZE >::is_ro_.
|
inline |
Get allocation pool.
Definition at line 453 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_, and bm::basic_bmatrix< BV >::get_allocator_pool().
|
inline |
access to internal bit-matrix
Definition at line 538 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_.
|
inline |
get read-only access to inetrnal bit-matrix
Definition at line 532 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_.
Referenced by bm::base_sparse_vector< Val, BV, MAX_SIZE >::copy_from(), deserialize_df2(), bm::sparse_vector< Val, BV >::join(), and bm::str_sparse_vector< CharType, BV, STR_SIZE >::remap_from_impl().
base_sparse_vector< Val, BV, MAX_SIZE >::bvector_type_ptr bm::base_sparse_vector< Val, BV, MAX_SIZE >::get_create_slice | ( | unsigned | i | ) |
get access to bit-plain, function checks and creates a plane
Definition at line 1730 of file bmbmatrix.h.
|
inline |
Definition at line 504 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_, bm::basic_bmatrix< BV >::get_null_idx(), and bm::basic_bmatrix< BV >::get_row().
|
inline |
Get bit-vector of assigned values or NULL (if not constructed that way)
Definition at line 430 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_, bm::basic_bmatrix< BV >::get_null_idx(), and bm::basic_bmatrix< BV >::get_row().
Referenced by bm::base_sparse_vector< Val, BV, MAX_SIZE >::copy_range_slices(), generate_random_subset(), main(), print_sorted(), and bm::str_sparse_vector< CharType, BV, STR_SIZE >::remap_from_impl().
|
inline |
check if container supports NULL (unassigned) values
Definition at line 423 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::is_nullable(), bm::no_null, and bm::use_null.
|
inline |
get read-only access to bit-plane
Definition at line 476 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_, and bm::basic_bmatrix< BV >::row().
bm::id64_t bm::base_sparse_vector< Val, BV, MAX_SIZE >::get_slice_mask | ( | unsigned | element_idx | ) | const |
return mask of allocated bit-planes 1 in the mask - means bit-plane N is present returns 64-bit unsigned mask for sub 64-bit types (like int) unallocated mask bits will be zero extended
Definition at line 1749 of file bmbmatrix.h.
|
protected |
insert false (clear) column in all value planes
plane_idx | - row (plane index to start from) |
idx | - bit (column) to clear insert |
Definition at line 1822 of file bmbmatrix.h.
|
protected |
insert (NOT) NULL value
Definition at line 1719 of file bmbmatrix.h.
bool bm::base_sparse_vector< Val, BV, MAX_SIZE >::is_null | ( | size_type | idx | ) | const |
test if specified element is NULL
idx | - element index |
Definition at line 1709 of file bmbmatrix.h.
Referenced by bm::str_sparse_vector< CharType, BV, STR_SIZE >::const_iterator::is_null(), and print_svector().
|
inline |
check if container supports NULL(unassigned) values
Definition at line 418 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_, and bm::basic_bmatrix< BV >::get_null_idx().
Referenced by bm::base_sparse_vector< Val, BV, MAX_SIZE >::get_null_support(), bm::sparse_vector< Val, BV >::join_null_slice(), and bm::str_sparse_vector< CharType, BV, STR_SIZE >::merge().
|
inlinestaticconstexpr |
returns true if value type is signed integral type
Definition at line 412 of file bmbmatrix.h.
void bm::base_sparse_vector< Val, BV, MAX_SIZE >::keep_range_no_check | ( | size_type | left, |
size_type | right, | ||
bm::null_support | slice_null | ||
) |
Definition at line 1677 of file bmbmatrix.h.
References bm::use_null.
|
inline |
Set NULL plain index.
Definition at line 544 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_, and bm::basic_bmatrix< BV >::null_idx_.
|
protected |
Merge plane bvectors from an outside base matrix Note: outside base matrix gets destroyed.
Definition at line 1585 of file bmbmatrix.h.
References BM_ASSERT, bm::basic_bmatrix< BV >::get_null_idx(), bm::basic_bmatrix< BV >::get_row(), and bm::basic_bmatrix< BV >::rows().
void bm::base_sparse_vector< Val, BV, MAX_SIZE >::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
temp_block | - pre-allocated memory block to avoid unnecessary re-allocs |
opt_mode | - requested compression depth |
stat | - memory allocation statistics after optimization |
Definition at line 1767 of file bmbmatrix.h.
References bm::bv_statistics::add().
|
inlineprotected |
plane index for the "NOT NULL" flags plane
optimize block in all matrix planes
Definition at line 664 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_, and bm::basic_bmatrix< BV >::optimize_block().
|
static |
Convert signed value type to unsigned representation.
Definition at line 1947 of file bmbmatrix.h.
|
inline |
Set allocation pool.
Definition at line 447 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_, and bm::basic_bmatrix< BV >::set_allocator_pool().
|
inline |
Definition at line 385 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::size_.
Referenced by bm::base_sparse_vector< Val, BV, MAX_SIZE >::copy_from(), and bm::base_sparse_vector< Val, BV, MAX_SIZE >::empty().
|
inline |
get access to bit-plane as is (can return NULL)
Definition at line 500 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_, and bm::basic_bmatrix< BV >::get_row().
|
inline |
Definition at line 501 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::bmatr_, and bm::basic_bmatrix< BV >::get_row().
|
inlinestatic |
get total number of bit-planes in the vector
Definition at line 482 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::value_bits().
|
inlinestatic |
Number of stored bit-planes (value planes + extra.
Definition at line 487 of file bmbmatrix.h.
References bm::base_sparse_vector< Val, BV, MAX_SIZE >::value_bits().
void bm::base_sparse_vector< Val, BV, MAX_SIZE >::swap | ( | base_sparse_vector< Val, BV, MAX_SIZE > & | bsv | ) |
Definition at line 1624 of file bmbmatrix.h.
References bm::xor_swap().
|
static |
Convert unsigned value type to signed representation.
Definition at line 1968 of file bmbmatrix.h.
|
inlinestaticconstexprprotected |
Number of total bit-planes in the value type.
Definition at line 657 of file bmbmatrix.h.
Referenced by bm::base_sparse_vector< Val, BV, MAX_SIZE >::slices(), and bm::base_sparse_vector< Val, BV, MAX_SIZE >::stored_slices().
|
protected |
bit-transposed matrix
Definition at line 677 of file bmbmatrix.h.
Referenced by bm::base_sparse_vector< Val, BV, MAX_SIZE >::base_sparse_vector(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::bit_and_rows(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::bit_sub_rows(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::copy_from(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::copy_range_slices(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::free_slice(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::freeze_matr(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::get_allocator_pool(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::get_bmatrix(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::get_null_bvect(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::get_null_bvector(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::get_slice(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::is_nullable(), bm::sparse_vector< Val, BV >::join(), bm::sparse_vector< Val, BV >::join_null_slice(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::mark_null_idx(), bm::sparse_vector< Val, BV >::merge(), bm::str_sparse_vector< CharType, BV, STR_SIZE >::merge(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::optimize_block(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::set_allocator_pool(), and bm::base_sparse_vector< Val, BV, MAX_SIZE >::slice().
|
protected |
number of bit slices actually allocated
Definition at line 680 of file bmbmatrix.h.
Referenced by bm::base_sparse_vector< Val, BV, MAX_SIZE >::base_sparse_vector(), bm::base_sparse_vector< Val, BV, MAX_SIZE >::copy_from(), and bm::base_sparse_vector< Val, BV, MAX_SIZE >::effective_slices().
|
protected |
read-only
Definition at line 681 of file bmbmatrix.h.
Referenced by bm::base_sparse_vector< Val, BV, MAX_SIZE >::freeze_matr().
|
protected |
array size
Definition at line 679 of file bmbmatrix.h.
Referenced by bm::base_sparse_vector< Val, BV, MAX_SIZE >::base_sparse_vector(), and bm::base_sparse_vector< Val, BV, MAX_SIZE >::size().
|
protected |
slice presence bit-mask
Definition at line 678 of file bmbmatrix.h.
Referenced by bm::base_sparse_vector< Val, BV, MAX_SIZE >::base_sparse_vector().