BitMagic-C++
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends
bm::bvector< Alloc > Class Template Reference

Bitvector Bit-vector container with runtime compression of bits. More...

#include <bm.h>

Inheritance diagram for bm::bvector< Alloc >:
Inheritance graph
[legend]

Data Structures

struct  allocation_policy
 memory allocation policy More...
 
class  bulk_insert_iterator
 Output iterator iterator designed to set "ON" bits based on input sequence of integers. More...
 
class  counted_enumerator
 Constant iterator designed to enumerate "ON" bits counted_enumerator keeps bitcount, ie number of ON bits starting from the position 0 in the bit string up to the currently enumerated bit. More...
 
class  enumerator
 Constant iterator designed to enumerate "ON" bits. More...
 
class  insert_iterator
 Output iterator iterator designed to set "ON" bits based on input sequence of integers (bit indeces). More...
 
class  iterator_base
 Base class for all iterators. More...
 
class  mem_pool_guard
 
class  reference
 Class reference implements an object for bit assignment. More...
 
struct  statistics
 Statistical information about bitset's memory allocation details. More...
 

Public Types

enum  optmode { opt_none = 0, opt_free_0 = 1, opt_free_01 = 2, opt_compress = 3 }
 Optimization mode Every next level means additional checks (better compression vs time) More...
 
typedef Alloc allocator_type
 
typedef allocator_type::allocator_pool_type allocator_pool_type
 
typedef blocks_manager< Alloc > blocks_manager_type
 
typedef bm::id_t size_type
 
typedef bool const_reference
 
typedef rs_index blocks_count
 
typedef rs_index rs_index_type
 

Public Member Functions

reference operator[] (bm::id_t n)
 
bool operator[] (bm::id_t n) const
 
void operator&= (const bvector< Alloc > &bv)
 
void operator^= (const bvector< Alloc > &bv)
 
void operator|= (const bvector< Alloc > &bv)
 
void operator-= (const bvector< Alloc > &bv)
 
bool operator< (const bvector< Alloc > &bv) const
 
bool operator<= (const bvector< Alloc > &bv) const
 
bool operator> (const bvector< Alloc > &bv) const
 
bool operator>= (const bvector< Alloc > &bv) const
 
bool operator== (const bvector< Alloc > &bv) const
 
bool operator!= (const bvector< Alloc > &bv) const
 
bvector< Alloc > operator~ () const
 
Alloc get_allocator () const
 
void set_allocator_pool (allocator_pool_type *pool_ptr)
 Set allocator pool for local (non-threaded) memory cyclic(lots of alloc-free ops) opertations. More...
 
allocator_pool_typeget_allocator_pool ()
 Get curent allocator pool (if set) More...
 
insert_iterator inserter ()
 
Construction, initialization, assignment
 bvector (strategy strat=BM_BIT, const gap_word_t *glevel_len=bm::gap_len_table< true >::_len, size_type bv_size=bm::id_max, const Alloc &alloc=Alloc())
 Constructs bvector class. More...
 
 bvector (size_type bv_size, strategy strat=BM_BIT, const gap_word_t *glevel_len=bm::gap_len_table< true >::_len, const Alloc &alloc=Alloc())
 Constructs bvector class. More...
 
 bvector (const bvector< Alloc > &bvect)
 Copy constructor. More...
 
 bvector (const bvector< Alloc > &bvect, bm::id_t left, bm::id_t right)
 Copy constructor for range copy [left..right]. More...
 
 ~bvector () BMNOEXEPT
 
void init ()
 Explicit post-construction initialization. More...
 
bvectoroperator= (const bvector< Alloc > &bvect)
 Copy assignment operator. More...
 
 bvector (bvector< Alloc > &&bvect) BMNOEXEPT
 Move constructor. More...
 
 bvector (std::initializer_list< bm::id_t > il)
 Brace constructor. More...
 
bvectoroperator= (bvector< Alloc > &&bvect) BMNOEXEPT
 Move assignment operator. More...
 
void move_from (bvector< Alloc > &bvect) BMNOEXEPT
 Move bvector content from another bvector. More...
 
void swap (bvector< Alloc > &bvect) BMNOEXEPT
 Exchanges content of bv and this bvector. More...
 
void merge (bm::bvector< Alloc > &bvect)
 Merge/move content from another vector. More...
 
Bit access/modification methods
bool set_bit (bm::id_t n, bool val=true)
 Sets bit n. More...
 
bool set_bit_and (bm::id_t n, bool val=true)
 Sets bit n using bit AND with the provided value. More...
 
bool inc (bm::id_t n)
 Increment the specified element. More...
 
bool set_bit_conditional (bm::id_t n, bool val, bool condition)
 Sets bit n only if current value equals the condition. More...
 
bvector< Alloc > & set (bm::id_t n, bool val=true)
 Sets bit n if val is true, clears bit n if val is false. More...
 
bvector< Alloc > & set ()
 Sets every bit in this bitset to 1. More...
 
void set (const bm::id_t *ids, unsigned ids_size, bm::sort_order so=bm::BM_UNKNOWN)
 Set list of bits in this bitset to 1. More...
 
void keep (const bm::id_t *ids, unsigned ids_size, bm::sort_order so=bm::BM_UNKNOWN)
 Keep list of bits in this bitset, others are cleared. More...
 
void clear (const bm::id_t *ids, unsigned ids_size, bm::sort_order so=bm::BM_UNKNOWN)
 clear list of bits in this bitset More...
 
void set_bit_no_check (bm::id_t n)
 Set bit without checking preconditions (size, etc) More...
 
bvector< Alloc > & set_range (bm::id_t left, bm::id_t right, bool value=true)
 Sets all bits in the specified closed interval [left,right] Interval must be inside the bvector's size. This method DOES NOT resize vector. More...
 
void copy_range (const bvector< Alloc > &bvect, bm::id_t left, bm::id_t right)
 Copy all bits in the specified closed interval [left,right]. More...
 
bool clear_bit (bm::id_t n)
 Clears bit n. More...
 
void clear_bit_no_check (bm::id_t n)
 Clears bit n without precondiion checks. More...
 
void clear (bool free_mem=false)
 Clears every bit in the bitvector. More...
 
bvector< Alloc > & reset ()
 Clears every bit in the bitvector. More...
 
bvector< Alloc > & flip (bm::id_t n)
 Flips bit n. More...
 
bvector< Alloc > & flip ()
 Flips all bits. More...
 
Size and capacity

By default bvector is dynamically sized, manual control methods available

size_type capacity () const
 Returns bvector's capacity (number of bits it can store) More...
 
size_type size () const
 return current size of the vector (bits) More...
 
void resize (size_type new_size)
 Change size of the bvector. More...
 
Population counting and ranking methods
bm::id_t count () const
 population cout (count of ON bits) More...
 
unsigned count_blocks (unsigned *arr) const
 Computes bitcount values for all bvector blocks. More...
 
bm::id_t count_range (bm::id_t left, bm::id_t right, const unsigned *block_count_arr=0) const
 Returns count of 1 bits in the given range. More...
 
void running_count_blocks (rs_index_type *blocks_cnt) const
 compute running total of all blocks in bit vector More...
 
void build_rs_index (rs_index_type *rs_idx) const
 compute running total of all blocks in bit vector (rank-select index) More...
 
bm::id_t count_to (bm::id_t n, const rs_index_type &blocks_cnt) const
 Returns count of 1 bits (population) in [0..right] range. More...
 
bm::id_t rank (bm::id_t n, const rs_index_type &rs_idx) const
 Returns rank of specified bit position. More...
 
bm::id_t count_to_test (bm::id_t n, const rs_index_type &blocks_cnt) const
 Returns count of 1 bits (population) in [0..right] range if test(right) == true. More...
 
bm::id_t recalc_count ()
 
void forget_count ()
 
Bit access (read-only)
bool get_bit (bm::id_t n) const
 returns true if bit n is set and false is bit n is 0. More...
 
bool test (bm::id_t n) const
 returns true if bit n is set and false is bit n is 0. More...
 
bit-shift and insert operations
bool shift_right ()
 Shift right by 1 bit, fill with zero return carry over. More...
 
bool insert (bm::id_t n, bool value)
 Insert bit into specified position All the vector content after position is shifted right. More...
 
Check for empty-ness of container
bool any () const
 Returns true if any bits in this bitset are set, and otherwise returns false. More...
 
bool none () const
 Returns true if no bits are set, otherwise returns false. More...
 
Scan and find bits and indexes
bool find (bm::id_t &pos) const
 Finds index of first 1 bit. More...
 
bool find (bm::id_t from, bm::id_t &pos) const
 Finds index of 1 bit starting from position. More...
 
bm::id_t get_first () const
 find first 1 bit in vector. Function may return 0 and this requires an extra check if bit 0 is actually set or bit-vector is empty More...
 
bm::id_t get_next (bm::id_t prev) const
 Finds the number of the next bit ON. More...
 
bm::id_t extract_next (bm::id_t prev)
 Finds the number of the next bit ON and sets it to 0. More...
 
bool find_reverse (bm::id_t &pos) const
 Finds last index of 1 bit. More...
 
bool find_range (bm::id_t &first, bm::id_t &last) const
 Finds dynamic range of bit-vector [first, last]. More...
 
bool find_rank (bm::id_t rank, bm::id_t from, bm::id_t &pos) const
 Find bit-vector position for the specified rank(bitcount) More...
 
bool find_rank (bm::id_t rank, bm::id_t from, bm::id_t &pos, const rs_index_type &blocks_cnt) const
 Find bit-vector position for the specified rank(bitcount) More...
 
bool select (bm::id_t rank, bm::id_t &pos, const rs_index_type &blocks_cnt) const
 select bit-vector position for the specified rank(bitcount) More...
 
Algebra of Sets operations
bm::bvector< Alloc > & bit_or (const bm::bvector< Alloc > &bv1, const bm::bvector< Alloc > &bv2, typename bm::bvector< Alloc >::optmode opt_mode)
 3-operand OR : this := bv1 OR bv2 More...
 
bm::bvector< Alloc > & bit_xor (const bm::bvector< Alloc > &bv1, const bm::bvector< Alloc > &bv2, typename bm::bvector< Alloc >::optmode opt_mode)
 3-operand XOR : this := bv1 XOR bv2 More...
 
bm::bvector< Alloc > & bit_and (const bm::bvector< Alloc > &bv1, const bm::bvector< Alloc > &bv2, typename bm::bvector< Alloc >::optmode opt_mode)
 3-operand AND : this := bv1 AND bv2 More...
 
bm::bvector< Alloc > & bit_sub (const bm::bvector< Alloc > &bv1, const bm::bvector< Alloc > &bv2, typename bm::bvector< Alloc >::optmode opt_mode)
 3-operand SUB : this := bv1 MINUS bv2 SUBtraction is also known as AND NOT More...
 
bm::bvector< Alloc > & bit_or (const bm::bvector< Alloc > &bv)
 2 operand logical OR More...
 
bm::bvector< Alloc > & bit_and (const bm::bvector< Alloc > &bv)
 2 operand logical AND More...
 
bm::bvector< Alloc > & bit_xor (const bm::bvector< Alloc > &bv)
 2 operand logical XOR More...
 
bm::bvector< Alloc > & bit_sub (const bm::bvector< Alloc > &bv)
 2 operand logical SUB(AND NOT). Also known as MINUS. More...
 
bvector< Alloc > & invert ()
 Invert/NEG all bits It should be noted, invert is affected by size() if size is set - it only inverts [0..size-1] bits. More...
 
void combine_operation (const bm::bvector< Alloc > &bvect, bm::operation opcode)
 perform a set-algebra operation by operation code More...
 
void combine_operation_or (const bm::bvector< Alloc > &bvect)
 perform a set-algebra operation OR More...
 
void combine_operation_and (const bm::bvector< Alloc > &bvect)
 perform a set-algebra operation AND More...
 
void combine_operation_sub (const bm::bvector< Alloc > &bvect)
 perform a set-algebra operation MINUS (AND NOT) More...
 
void combine_operation_xor (const bm::bvector< Alloc > &bvect)
 perform a set-algebra operation XOR More...
 
Iterator-traversal methods
enumerator first () const
 Returns enumerator pointing on the first non-zero bit. More...
 
enumerator end () const
 Returns enumerator pointing on the next bit after the last. More...
 
enumerator get_enumerator (bm::id_t pos) const
 Returns enumerator pointing on specified or the next available bit. More...
 
Memory management and compression
void calc_stat (struct bm::bvector< Alloc >::statistics *st) const
 Calculates bitvector statistics. More...
 
void set_new_blocks_strat (strategy strat)
 Sets new blocks allocation strategy. More...
 
strategy get_new_blocks_strat () const
 Returns blocks allocation strategy. More...
 
void optimize (bm::word_t *temp_block=0, optmode opt_mode=opt_compress, statistics *stat=0)
 Optimize memory bitvector's memory allocation. More...
 
void optimize_gap_size ()
 Optimize sizes of GAP blocks. More...
 
void set_gap_levels (const gap_word_t *glevel_len)
 Sets new GAP lengths table. All GAP blocks will be reallocated to match the new scheme. More...
 
Comparison
int compare (const bvector< Alloc > &bvect) const
 Lexicographical comparison with a bitvector. More...
 
Open internals
void combine_operation_with_block (unsigned nb, const bm::word_t *arg_blk, bool arg_gap, bm::operation opcode)
 
const blocks_manager_typeget_blocks_manager () const
 get access to memory manager (internal) Use only if you are BitMagic library More...
 
blocks_manager_typeget_blocks_manager ()
 get access to memory manager (internal) Use only if you are BitMagic library More...
 

Static Public Member Functions

static void throw_bad_alloc ()
 

Protected Member Functions

void sync_size ()
 Syncronize size if it got extended due to bulk import. More...
 
void import (const bm::id_t *ids, unsigned ids_size, bm::sort_order sorted_idx)
 Import integers (set bits). More...
 
void import_block (const bm::id_t *ids, bm::id_t nblock, bm::id_t start, bm::id_t stop)
 

Friends

class iterator_base
 
class enumerator
 
template<class BV >
class aggregator
 

Detailed Description

template<class Alloc>
class bm::bvector< Alloc >

Bitvector Bit-vector container with runtime compression of bits.

Examples:
bvsetalgebra.cpp, sample14.cpp, sample4.cpp, and sample6.cpp.

Definition at line 135 of file bm.h.

Member Typedef Documentation

◆ allocator_pool_type

template<class Alloc>
typedef allocator_type::allocator_pool_type bm::bvector< Alloc >::allocator_pool_type

Definition at line 139 of file bm.h.

◆ allocator_type

template<class Alloc>
typedef Alloc bm::bvector< Alloc >::allocator_type

Definition at line 138 of file bm.h.

◆ blocks_count

template<class Alloc>
typedef rs_index bm::bvector< Alloc >::blocks_count

Definition at line 1254 of file bm.h.

◆ blocks_manager_type

template<class Alloc>
typedef blocks_manager<Alloc> bm::bvector< Alloc >::blocks_manager_type

Definition at line 140 of file bm.h.

◆ const_reference

template<class Alloc>
typedef bool bm::bvector< Alloc >::const_reference

Definition at line 253 of file bm.h.

◆ rs_index_type

template<class Alloc>
typedef rs_index bm::bvector< Alloc >::rs_index_type

Definition at line 1255 of file bm.h.

◆ size_type

template<class Alloc>
typedef bm::id_t bm::bvector< Alloc >::size_type

Definition at line 141 of file bm.h.

Member Enumeration Documentation

◆ optmode

template<class Alloc>
enum bm::bvector::optmode

Optimization mode Every next level means additional checks (better compression vs time)

See also
optimize
Enumerator
opt_none 

no optimization

opt_free_0 

Free unused 0 blocks.

opt_free_01 

Free unused 0 and 1 blocks.

opt_compress 

compress blocks when possible (GAP/prefix sum)

Definition at line 152 of file bm.h.

Constructor & Destructor Documentation

◆ bvector() [1/6]

template<class Alloc>
bm::bvector< Alloc >::bvector ( strategy  strat = BM_BIT,
const gap_word_t glevel_len = bm::gap_len_table<true>::_len,
size_type  bv_size = bm::id_max,
const Alloc &  alloc = Alloc() 
)
inline

Constructs bvector class.

Parameters
strat- operation mode strategy, BM_BIT - default strategy, bvector use plain bitset blocks, (performance oriented strategy). BM_GAP - memory effitent strategy, bvector allocates blocks as array of intervals(gaps) and convert blocks into plain bitsets only when enthropy grows.
glevel_len
bv_size
  • bvector size (number of bits addressable by bvector), bm::id_max means "no limits" (recommended). bit vector allocates this space dynamically on demand.
alloc- alllocator for this instance
See also
bm::gap_len_table bm::gap_len_table_min set_new_blocks_strat

Definition at line 1281 of file bm.h.

◆ bvector() [2/6]

template<class Alloc>
bm::bvector< Alloc >::bvector ( size_type  bv_size,
strategy  strat = BM_BIT,
const gap_word_t glevel_len = bm::gap_len_table<true>::_len,
const Alloc &  alloc = Alloc() 
)
inline

Constructs bvector class.

Definition at line 1293 of file bm.h.

◆ bvector() [3/6]

template<class Alloc>
bm::bvector< Alloc >::bvector ( const bvector< Alloc > &  bvect)
inline

Copy constructor.

Definition at line 1305 of file bm.h.

◆ bvector() [4/6]

template<class Alloc>
bm::bvector< Alloc >::bvector ( const bvector< Alloc > &  bvect,
bm::id_t  left,
bm::id_t  right 
)
inline

Copy constructor for range copy [left..right].

See also
copy_range

Definition at line 1316 of file bm.h.

◆ ~bvector()

template<class Alloc>
bm::bvector< Alloc >::~bvector ( )
inline

Definition at line 1329 of file bm.h.

◆ bvector() [5/6]

template<class Alloc>
bm::bvector< Alloc >::bvector ( bvector< Alloc > &&  bvect)
inline

Move constructor.

Definition at line 1353 of file bm.h.

◆ bvector() [6/6]

template<class Alloc>
bm::bvector< Alloc >::bvector ( std::initializer_list< bm::id_t il)
inline

Brace constructor.

Definition at line 1364 of file bm.h.

Member Function Documentation

◆ any()

template<typename Alloc >
bool bm::bvector< Alloc >::any ( ) const

Returns true if any bits in this bitset are set, and otherwise returns false.

Returns
true if any bit is set

Definition at line 2486 of file bm.h.

Referenced by DNA_FingerprintScanner::Find().

◆ bit_and() [1/2]

template<class Alloc>
bm::bvector< Alloc > & bm::bvector< Alloc >::bit_and ( const bm::bvector< Alloc > &  bv1,
const bm::bvector< Alloc > &  bv2,
typename bm::bvector< Alloc >::optmode  opt_mode 
)

3-operand AND : this := bv1 AND bv2

Parameters
bv1- Argument vector 1
bv2- Argument vector 2
opt_mode- optimization compression (when it is performed on the fly it is faster than a separate call to optimize()
See also
optimize, bit_and

Definition at line 4552 of file bm.h.

Referenced by DemoAND(), bm::sparse_vector< unsigned, bm::bvector<> >::filter(), and bm::operator &().

◆ bit_and() [2/2]

template<class Alloc>
bm::bvector<Alloc>& bm::bvector< Alloc >::bit_and ( const bm::bvector< Alloc > &  bv)
inline

2 operand logical AND

Parameters
bv- argument vector.

Definition at line 2034 of file bm.h.

◆ bit_or() [1/2]

template<class Alloc>
bm::bvector< Alloc > & bm::bvector< Alloc >::bit_or ( const bm::bvector< Alloc > &  bv1,
const bm::bvector< Alloc > &  bv2,
typename bm::bvector< Alloc >::optmode  opt_mode 
)

3-operand OR : this := bv1 OR bv2

Parameters
bv1- Argument vector 1
bv2- Argument vector 2
opt_mode- optimization compression (when it is performed on the fly it is faster than a separate call to optimize()
See also
optimize, bit_or

Definition at line 4386 of file bm.h.

Referenced by DemoOR(), bm::dynamic_range_clip_high(), bm::dynamic_range_clip_low(), and bm::operator|().

◆ bit_or() [2/2]

template<class Alloc>
bm::bvector<Alloc>& bm::bvector< Alloc >::bit_or ( const bm::bvector< Alloc > &  bv)
inline

2 operand logical OR

Parameters
bv- Argument vector.

Definition at line 2024 of file bm.h.

◆ bit_sub() [1/2]

template<class Alloc>
bm::bvector< Alloc > & bm::bvector< Alloc >::bit_sub ( const bm::bvector< Alloc > &  bv1,
const bm::bvector< Alloc > &  bv2,
typename bm::bvector< Alloc >::optmode  opt_mode 
)

3-operand SUB : this := bv1 MINUS bv2 SUBtraction is also known as AND NOT

Parameters
bv1- Argument vector 1
bv2- Argument vector 2
opt_mode- optimization compression (when it is performed on the fly it is faster than a separate call to optimize()
See also
optimize, bit_sub

Definition at line 4637 of file bm.h.

Referenced by DemoSUB(), and bm::operator-().

◆ bit_sub() [2/2]

template<class Alloc>
bm::bvector<Alloc>& bm::bvector< Alloc >::bit_sub ( const bm::bvector< Alloc > &  bv)
inline

2 operand logical SUB(AND NOT). Also known as MINUS.

Parameters
bv- argument vector.

Definition at line 2054 of file bm.h.

◆ bit_xor() [1/2]

template<class Alloc>
bm::bvector< Alloc > & bm::bvector< Alloc >::bit_xor ( const bm::bvector< Alloc > &  bv1,
const bm::bvector< Alloc > &  bv2,
typename bm::bvector< Alloc >::optmode  opt_mode 
)

3-operand XOR : this := bv1 XOR bv2

Parameters
bv1- Argument vector 1
bv2- Argument vector 2
opt_mode- optimization compression (when it is performed on the fly it is faster than a separate call to optimize()
See also
optimize, bit_xor

Definition at line 4464 of file bm.h.

Referenced by DemoXOR(), and bm::operator^().

◆ bit_xor() [2/2]

template<class Alloc>
bm::bvector<Alloc>& bm::bvector< Alloc >::bit_xor ( const bm::bvector< Alloc > &  bv)
inline

2 operand logical XOR

Parameters
bv- argument vector.

Definition at line 2044 of file bm.h.

◆ build_rs_index()

template<class Alloc>
void bm::bvector< Alloc >::build_rs_index ( rs_index_type rs_idx) const
inline

compute running total of all blocks in bit vector (rank-select index)

Parameters
rs_idx- [out] pointer to index / count structure Function will fill full array of running totals
See also
count_to, select, find_rank

Definition at line 1712 of file bm.h.

Referenced by bv_count_to_acc(), and bv_count_to_range_acc().

◆ calc_stat()

template<typename Alloc>
void bm::bvector< Alloc >::calc_stat ( struct bm::bvector< Alloc >::statistics st) const

Calculates bitvector statistics.

Parameters
st- pointer on statistics structure to be filled in.

Function fills statistics structure containing information about how this vector uses memory and estimation of max. amount of memory bvector needs to serialize itself.

See also
statistics
Examples:
xsample01.cpp.

Definition at line 3193 of file bm.h.

Referenced by calc_memory_footprint(), convert_bv2bvs(), generate_bvector(), and print_statistics().

◆ capacity()

template<class Alloc>
size_type bm::bvector< Alloc >::capacity ( ) const
inline

Returns bvector's capacity (number of bits it can store)

Definition at line 1654 of file bm.h.

◆ clear() [1/2]

template<class Alloc >
void bm::bvector< Alloc >::clear ( const bm::id_t ids,
unsigned  ids_size,
bm::sort_order  so = bm::BM_UNKNOWN 
)

clear list of bits in this bitset

This is equivalent of AND NOT (Set Substract), argument set as an array.

Parameters
ids- pointer on array of indexes to set
ids_size- size of the input (ids)
so- sort order (use BM_SORTED for faster load)
See also
set, keep
Examples:
xsample01.cpp.

Definition at line 3332 of file bm.h.

Referenced by bv_count_and(), DemoSUB(), main(), speed_test_bv_index(), speed_test_bvs_index(), speed_test_sv_index(), and speed_test_vect_index().

◆ clear() [2/2]

template<class Alloc>
void bm::bvector< Alloc >::clear ( bool  free_mem = false)
inline

Clears every bit in the bitvector.

Parameters
free_memif "true" (default) bvector frees the memory, otherwise sets blocks to 0.

Definition at line 1611 of file bm.h.

◆ clear_bit()

template<class Alloc>
bool bm::bvector< Alloc >::clear_bit ( bm::id_t  n)
inline

Clears bit n.

Parameters
n- bit's index to be cleaned.
Returns
true if bit was cleared

Definition at line 1597 of file bm.h.

◆ clear_bit_no_check()

template<class Alloc>
void bm::bvector< Alloc >::clear_bit_no_check ( bm::id_t  n)
inline

Clears bit n without precondiion checks.

Parameters
n- bit's index to be cleaned.

Definition at line 1603 of file bm.h.

Referenced by bm::basic_bmatrix< bm::bvector<> >::set_octet(), and bm::sparse_vector< unsigned, bm::bvector<> >::set_value_no_null().

◆ combine_operation()

template<class Alloc>
void bm::bvector< Alloc >::combine_operation ( const bm::bvector< Alloc > &  bvect,
bm::operation  opcode 
)

perform a set-algebra operation by operation code

Definition at line 4995 of file bm.h.

Referenced by DemoAND(), DemoOR(), DemoSUB(), and DemoXOR().

◆ combine_operation_and()

template<class Alloc>
void bm::bvector< Alloc >::combine_operation_and ( const bm::bvector< Alloc > &  bvect)

perform a set-algebra operation AND

Definition at line 4863 of file bm.h.

◆ combine_operation_or()

template<class Alloc>
void bm::bvector< Alloc >::combine_operation_or ( const bm::bvector< Alloc > &  bvect)

perform a set-algebra operation OR

Definition at line 4730 of file bm.h.

◆ combine_operation_sub()

template<class Alloc>
void bm::bvector< Alloc >::combine_operation_sub ( const bm::bvector< Alloc > &  bvect)

perform a set-algebra operation MINUS (AND NOT)

Definition at line 4937 of file bm.h.

◆ combine_operation_with_block()

template<class Alloc >
void bm::bvector< Alloc >::combine_operation_with_block ( unsigned  nb,
const bm::word_t arg_blk,
bool  arg_gap,
bm::operation  opcode 
)

Definition at line 4372 of file bm.h.

Referenced by bm::bvector<>::combine_operation().

◆ combine_operation_xor()

template<class Alloc>
void bm::bvector< Alloc >::combine_operation_xor ( const bm::bvector< Alloc > &  bvect)

perform a set-algebra operation XOR

Definition at line 4794 of file bm.h.

◆ compare()

template<typename Alloc>
int bm::bvector< Alloc >::compare ( const bvector< Alloc > &  bvect) const

Lexicographical comparison with a bitvector.

Function compares current bitvector with the provided argument bit by bit and returns -1 if our bitvector less than the argument, 1 - greater, 0 - equal.

Examples:
xsample01.cpp.

Definition at line 3051 of file bm.h.

Referenced by convert_bv2bvs(), fingerprint_compare(), main(), and run_benchmark().

◆ copy_range()

template<class Alloc>
void bm::bvector< Alloc >::copy_range ( const bvector< Alloc > &  bvect,
bm::id_t  left,
bm::id_t  right 
)

Copy all bits in the specified closed interval [left,right].

Parameters
bvect- source bit-vector
left- interval start
right- interval end (closed interval)

Definition at line 6127 of file bm.h.

Referenced by bm::sparse_vector< unsigned, bm::bvector<> >::copy_range(), and bm::sparse_vector< unsigned, bm::bvector<> >::extract().

◆ count()

template<typename Alloc >
bm::id_t bm::bvector< Alloc >::count ( ) const

population cout (count of ON bits)

Returns
Total number of bits ON.
Examples:
xsample01.cpp.

Definition at line 2468 of file bm.h.

Referenced by bv_count_test(), convert_bv2vect(), main(), pre_heat(), print_bvector(), print_statistics(), run_benchmark(), and serialize_bvector().

◆ count_blocks()

template<typename Alloc >
unsigned bm::bvector< Alloc >::count_blocks ( unsigned *  arr) const

Computes bitcount values for all bvector blocks.

Parameters
arr- pointer on array of block bit counts
Returns
Index of the last block counted. This number +1 gives you number of arr elements initialized during the function call.

Definition at line 2591 of file bm.h.

Referenced by bv_count_range_acc().

◆ count_range()

template<typename Alloc >
bm::id_t bm::bvector< Alloc >::count_range ( bm::id_t  left,
bm::id_t  right,
const unsigned *  block_count_arr = 0 
) const

Returns count of 1 bits in the given range.

Parameters
left- index of first bit start counting from
right- index of last bit
block_count_arr- optional parameter (bitcount by bvector blocks) calculated by count_blocks method. Used to improve performance of wide range searches
Returns
population count in the diapason

Definition at line 2814 of file bm.h.

Referenced by bv_count_range(), and bv_count_range_acc().

◆ count_to()

template<typename Alloc >
bm::id_t bm::bvector< Alloc >::count_to ( bm::id_t  n,
const rs_index_type blocks_cnt 
) const

Returns count of 1 bits (population) in [0..right] range.

This operation is also known as rank of bit N.

Parameters
n- index of bit to rank
blocks_cnt- block count structure to accelerate search should be prepared using build_rs_index
Returns
population count in the range [0..n]
See also
build_rs_index
count_to_test, select, rank

Definition at line 2716 of file bm.h.

Referenced by bv_count_to_acc(), and bv_count_to_range_acc().

◆ count_to_test()

template<typename Alloc >
bm::id_t bm::bvector< Alloc >::count_to_test ( bm::id_t  n,
const rs_index_type blocks_cnt 
) const

Returns count of 1 bits (population) in [0..right] range if test(right) == true.

This is conditional rank operation, which is faster than test() plus count_to()

Parameters
n- index of bit to test and rank
blocks_cnt- block count structure to accelerate search should be prepared using running_count_blocks
Returns
population count in the diapason or 0 if right bit test failed
See also
running_count_blocks
count_to

Definition at line 2760 of file bm.h.

◆ end()

template<class Alloc>
bvector::enumerator bm::bvector< Alloc >::end ( ) const
inline

Returns enumerator pointing on the next bit after the last.

Examples:
xsample01.cpp.

Definition at line 2104 of file bm.h.

Referenced by combine_or_test(), main(), speed_test_sv_index(), and speed_test_vect_index().

◆ extract_next()

template<class Alloc>
bm::id_t bm::bvector< Alloc >::extract_next ( bm::id_t  prev)
inline

Finds the number of the next bit ON and sets it to 0.

Parameters
prev- Index of the previously found bit.
Returns
Index of the next bit which is ON or 0 if not found.
See also
get_first, get_next, find_reverse

Definition at line 1883 of file bm.h.

◆ find() [1/2]

template<class Alloc >
bool bm::bvector< Alloc >::find ( bm::id_t pos) const

Finds index of first 1 bit.

Parameters
pos- index of the found 1 bit
Returns
true if search returned result
See also
get_first, get_next, extract_next, find_reverse

Definition at line 3779 of file bm.h.

Referenced by main().

◆ find() [2/2]

template<class Alloc >
bool bm::bvector< Alloc >::find ( bm::id_t  from,
bm::id_t pos 
) const

Finds index of 1 bit starting from position.

Parameters
from- position to start search from
pos- index of the found 1 bit
Returns
true if search returned result
See also
get_first, get_next, extract_next, find_reverse

Definition at line 3720 of file bm.h.

◆ find_range()

template<class Alloc >
bool bm::bvector< Alloc >::find_range ( bm::id_t first,
bm::id_t last 
) const

Finds dynamic range of bit-vector [first, last].

Parameters
first- index of the first found 1 bit
last- index of the last found 1 bit
Returns
true if search returned result
See also
get_first, get_next, extract_next, find, find_reverse

Definition at line 3821 of file bm.h.

Referenced by main().

◆ find_rank() [1/2]

template<class Alloc >
bool bm::bvector< Alloc >::find_rank ( bm::id_t  rank,
bm::id_t  from,
bm::id_t pos 
) const

Find bit-vector position for the specified rank(bitcount)

Rank based search, counts number of 1s from specified position until finds the ranked position relative to start from position. In other words: range population count between from and pos == rank.

Parameters
rank- rank to find (bitcount)
from- start positioon for rank search
pos- position with speciefied rank (relative to from position)
Returns
true if requested rank was found

Definition at line 3835 of file bm.h.

◆ find_rank() [2/2]

template<class Alloc >
bool bm::bvector< Alloc >::find_rank ( bm::id_t  rank,
bm::id_t  from,
bm::id_t pos,
const rs_index_type blocks_cnt 
) const

Find bit-vector position for the specified rank(bitcount)

Rank based search, counts number of 1s from specified position until finds the ranked position relative to start from position. In other words: range population count between from and pos == rank.

Parameters
rank- rank to find (bitcount)
from- start positioon for rank search
pos- position with speciefied rank (relative to from position)
blocks_cnt- block count structure to accelerate rank search should be prepared using running_count_blocks
See also
running_count_blocks, select
Returns
true if requested rank was found

Definition at line 3875 of file bm.h.

◆ find_reverse()

template<class Alloc >
bool bm::bvector< Alloc >::find_reverse ( bm::id_t pos) const

Finds last index of 1 bit.

Parameters
pos- index of the last found 1 bit
Returns
true if search returned result
See also
get_first, get_next, extract_next, find

Definition at line 3735 of file bm.h.

Referenced by bm::bvector<>::clear(), bm::bvector<>::keep(), and main().

◆ first()

template<class Alloc>
enumerator bm::bvector< Alloc >::first ( ) const
inline

◆ flip() [1/2]

template<class Alloc>
bvector<Alloc>& bm::bvector< Alloc >::flip ( bm::id_t  n)
inline

Flips bit n.

Returns
*this

Definition at line 1630 of file bm.h.

◆ flip() [2/2]

template<class Alloc>
bvector<Alloc>& bm::bvector< Alloc >::flip ( )
inline

Flips all bits.

Returns
*this
See also
invert

Definition at line 1637 of file bm.h.

◆ forget_count()

template<class Alloc>
void bm::bvector< Alloc >::forget_count ( )
inline

Disables count cache. (deprecated).

Definition at line 1768 of file bm.h.

◆ get_allocator()

template<class Alloc>
Alloc bm::bvector< Alloc >::get_allocator ( ) const
inline

Definition at line 1440 of file bm.h.

◆ get_allocator_pool()

template<class Alloc>
allocator_pool_type* bm::bvector< Alloc >::get_allocator_pool ( )
inline

Get curent allocator pool (if set)

Returns
pointer to the current pool or NULL

Definition at line 1453 of file bm.h.

Referenced by bm::bvector< Alloc >::mem_pool_guard::assign_if_not_set().

◆ get_bit()

template<typename Alloc >
bool bm::bvector< Alloc >::get_bit ( bm::id_t  n) const

returns true if bit n is set and false is bit n is 0.

Parameters
n- Index of the bit to check.
Returns
Bit value (1 or 0)

Definition at line 2933 of file bm.h.

◆ get_blocks_manager() [1/2]

template<class Alloc>
const blocks_manager_type& bm::bvector< Alloc >::get_blocks_manager ( ) const
inline

get access to memory manager (internal) Use only if you are BitMagic library

Definition at line 2215 of file bm.h.

Referenced by bm::bvector<>::bit_and(), bm::bvector<>::bit_or(), bm::bvector<>::bit_sub(), bm::bvector<>::bit_xor(), and bm::basic_bmatrix< bm::bvector<> >::get_block().

◆ get_blocks_manager() [2/2]

template<class Alloc>
blocks_manager_type& bm::bvector< Alloc >::get_blocks_manager ( )
inline

get access to memory manager (internal) Use only if you are BitMagic library

Definition at line 2222 of file bm.h.

◆ get_enumerator()

template<class Alloc>
enumerator bm::bvector< Alloc >::get_enumerator ( bm::id_t  pos) const
inline

Returns enumerator pointing on specified or the next available bit.

Definition at line 2110 of file bm.h.

◆ get_first()

template<class Alloc>
bm::id_t bm::bvector< Alloc >::get_first ( ) const
inline

find first 1 bit in vector. Function may return 0 and this requires an extra check if bit 0 is actually set or bit-vector is empty

Returns
Index of the first 1 bit, may return 0
See also
get_next, find, extract_next, find_reverse

Definition at line 1864 of file bm.h.

Referenced by print_bvector().

◆ get_new_blocks_strat()

template<class Alloc>
strategy bm::bvector< Alloc >::get_new_blocks_strat ( ) const
inline

Returns blocks allocation strategy.

Returns
- Strategy code 0 - bitblocks allocation only. 1 - Blocks mutation mode (adaptive algorithm)
See also
set_new_blocks_strat

Definition at line 2146 of file bm.h.

◆ get_next()

template<class Alloc>
bm::id_t bm::bvector< Alloc >::get_next ( bm::id_t  prev) const
inline

Finds the number of the next bit ON.

Parameters
prev- Index of the previously found bit.
Returns
Index of the next bit which is ON or 0 if not found.
See also
get_first, find, extract_next, find_reverse

Definition at line 1873 of file bm.h.

Referenced by print_bvector().

◆ import()

template<class Alloc >
void bm::bvector< Alloc >::import ( const bm::id_t ids,
unsigned  ids_size,
bm::sort_order  sorted_idx 
)
protected

Import integers (set bits).

(Fast, no checks).

Definition at line 3423 of file bm.h.

Referenced by bm::bvector<>::clear(), and bm::bvector<>::keep().

◆ import_block()

template<class Alloc >
void bm::bvector< Alloc >::import_block ( const bm::id_t ids,
bm::id_t  nblock,
bm::id_t  start,
bm::id_t  stop 
)
protected

Definition at line 3462 of file bm.h.

◆ inc()

template<class Alloc >
bool bm::bvector< Alloc >::inc ( bm::id_t  n)

Increment the specified element.

Bit increment rules: 0 + 1 = 1 (no carry over) 1 + 1 = 0 (with carry over returned)

Parameters
n- index of the bit to be set
Returns
TRUE if carry over created (1+1)

Definition at line 3557 of file bm.h.

Referenced by bm::sparse_vector< unsigned, bm::bvector<> >::inc().

◆ init()

template<typename Alloc >
void bm::bvector< Alloc >::init ( )

◆ insert()

template<class Alloc >
bool bm::bvector< Alloc >::insert ( bm::id_t  n,
bool  value 
)

Insert bit into specified position All the vector content after position is shifted right.

Parameters
n- index of the bit to insert
value- insert value
Returns
Carry over bit value (1 or 0)

Definition at line 4144 of file bm.h.

Referenced by bm::basic_bmatrix< bm::bvector<> >::insert_octet().

◆ inserter()

template<class Alloc>
insert_iterator bm::bvector< Alloc >::inserter ( )
inline

Function erturns insert iterator for this bitvector

Definition at line 1644 of file bm.h.

Referenced by main().

◆ invert()

template<typename Alloc >
bvector< Alloc > & bm::bvector< Alloc >::invert ( )

Invert/NEG all bits It should be noted, invert is affected by size() if size is set - it only inverts [0..size-1] bits.

Definition at line 2915 of file bm.h.

Referenced by DemoINV(), and bm::bvector<>::operator~().

◆ keep()

template<class Alloc >
void bm::bvector< Alloc >::keep ( const bm::id_t ids,
unsigned  ids_size,
bm::sort_order  so = bm::BM_UNKNOWN 
)

Keep list of bits in this bitset, others are cleared.

This is equivalent of AND (Set Intersect), argument set as an array.

Parameters
ids- pointer on array of indexes to set
ids_size- size of the input (ids)
so- sort order (use BM_SORTED for faster load)
See also
set, clear

Definition at line 3305 of file bm.h.

Referenced by DemoAND().

◆ merge()

template<class Alloc>
void bm::bvector< Alloc >::merge ( bm::bvector< Alloc > &  bvect)

Merge/move content from another vector.

Merge performs a logical OR operation, but the source vector is not immutable. Source content gets destroyed (memory moved) to create a union of two vectors. Merge operation can be more efficient than OR if argument is a temporary vector.

Parameters
bvect- [in, out] - source vector (NOT immutable)

Definition at line 4312 of file bm.h.

Referenced by DemoOR(), and bm::sparse_vector< unsigned, bm::bvector<> >::merge().

◆ move_from()

template<typename Alloc>
void bm::bvector< Alloc >::move_from ( bvector< Alloc > &  bvect)

Move bvector content from another bvector.

Definition at line 2416 of file bm.h.

◆ none()

template<class Alloc>
bool bm::bvector< Alloc >::none ( ) const
inline

Returns true if no bits are set, otherwise returns false.

Definition at line 1828 of file bm.h.

◆ operator!=()

template<class Alloc>
bool bm::bvector< Alloc >::operator!= ( const bvector< Alloc > &  bv) const
inline

Definition at line 1436 of file bm.h.

◆ operator&=()

template<class Alloc>
void bm::bvector< Alloc >::operator &= ( const bvector< Alloc > &  bv)
inline

Definition at line 1426 of file bm.h.

◆ operator-=()

template<class Alloc>
void bm::bvector< Alloc >::operator-= ( const bvector< Alloc > &  bv)
inline

Definition at line 1429 of file bm.h.

◆ operator<()

template<class Alloc>
bool bm::bvector< Alloc >::operator< ( const bvector< Alloc > &  bv) const
inline

Definition at line 1431 of file bm.h.

◆ operator<=()

template<class Alloc>
bool bm::bvector< Alloc >::operator<= ( const bvector< Alloc > &  bv) const
inline

Definition at line 1432 of file bm.h.

◆ operator=() [1/2]

template<class Alloc>
bvector& bm::bvector< Alloc >::operator= ( const bvector< Alloc > &  bvect)
inline

Copy assignment operator.

Definition at line 1338 of file bm.h.

◆ operator=() [2/2]

template<class Alloc>
bvector& bm::bvector< Alloc >::operator= ( bvector< Alloc > &&  bvect)
inline

Move assignment operator.

Definition at line 1381 of file bm.h.

◆ operator==()

template<class Alloc>
bool bm::bvector< Alloc >::operator== ( const bvector< Alloc > &  bv) const
inline

Definition at line 1435 of file bm.h.

◆ operator>()

template<class Alloc>
bool bm::bvector< Alloc >::operator> ( const bvector< Alloc > &  bv) const
inline

Definition at line 1433 of file bm.h.

◆ operator>=()

template<class Alloc>
bool bm::bvector< Alloc >::operator>= ( const bvector< Alloc > &  bv) const
inline

Definition at line 1434 of file bm.h.

◆ operator[]() [1/2]

template<class Alloc>
reference bm::bvector< Alloc >::operator[] ( bm::id_t  n)
inline

Definition at line 1410 of file bm.h.

◆ operator[]() [2/2]

template<class Alloc>
bool bm::bvector< Alloc >::operator[] ( bm::id_t  n) const
inline

Definition at line 1420 of file bm.h.

◆ operator^=()

template<class Alloc>
void bm::bvector< Alloc >::operator^= ( const bvector< Alloc > &  bv)
inline

Definition at line 1427 of file bm.h.

◆ operator|=()

template<class Alloc>
void bm::bvector< Alloc >::operator|= ( const bvector< Alloc > &  bv)
inline

Definition at line 1428 of file bm.h.

◆ operator~()

template<class Alloc>
bvector<Alloc> bm::bvector< Alloc >::operator~ ( ) const
inline

Definition at line 1438 of file bm.h.

◆ optimize()

template<typename Alloc >
void bm::bvector< Alloc >::optimize ( bm::word_t temp_block = 0,
optmode  opt_mode = opt_compress,
statistics stat = 0 
)

Optimize memory bitvector's memory allocation.

Function analyze all blocks in the bitvector, compresses blocks with a regular structure, frees some memory. This function is recommended after a bulk modification of the bitvector using set_bit, clear_bit or logical operations.

Optionally function can calculate vector post optimization statistics

See also
optmode, optimize_gap_size
Examples:
xsample01.cpp.

Definition at line 2964 of file bm.h.

Referenced by generate_bvector(), main(), make_BLOB(), bm::basic_bmatrix< bm::bvector<> >::optimize(), serialize_bvector(), speed_test_bv_index(), speed_test_bvs_index(), speed_test_sv_index(), and speed_test_vect_index().

◆ optimize_gap_size()

template<typename Alloc >
void bm::bvector< Alloc >::optimize_gap_size ( )

Optimize sizes of GAP blocks.

This method runs an analysis to find optimal GAP levels for the specific vector. Current GAP compression algorithm uses several fixed GAP sizes. By default bvector uses some reasonable preset.

Definition at line 3011 of file bm.h.

Referenced by bm::sparse_vector< unsigned, bm::bvector<> >::optimize_gap_size().

◆ rank()

template<class Alloc>
bm::id_t bm::bvector< Alloc >::rank ( bm::id_t  n,
const rs_index_type rs_idx 
) const
inline

Returns rank of specified bit position.

Parameters
n- index of bit to rank
rs_idx- rank-select index
Returns
population count in the range [0..n]
See also
build_rs_index
count_to_test, select, rank

Definition at line 1739 of file bm.h.

◆ recalc_count()

template<class Alloc>
bm::id_t bm::bvector< Alloc >::recalc_count ( )
inline

Recalculate bitcount (deprecated)

Definition at line 1763 of file bm.h.

◆ reset()

template<class Alloc>
bvector<Alloc>& bm::bvector< Alloc >::reset ( )
inline

Clears every bit in the bitvector.

Returns
*this;

Definition at line 1620 of file bm.h.

Referenced by bv_set_bit_test(), and generate_test_set().

◆ resize()

template<typename Alloc >
void bm::bvector< Alloc >::resize ( size_type  new_size)

Change size of the bvector.

Parameters
new_size- new size in bits

Definition at line 2498 of file bm.h.

Referenced by bm::bvector<>::clear(), convert_bv2sv(), DemoAND(), DemoINV(), DemoOR(), DemoSUB(), DemoXOR(), bm::bvector<>::keep(), and pick_benchmark_set().

◆ running_count_blocks()

template<typename Alloc >
void bm::bvector< Alloc >::running_count_blocks ( rs_index_type blocks_cnt) const

compute running total of all blocks in bit vector

Parameters
blocks_cnt- out pointer to counting structure, holding the array Function will fill full array of running totals
See also
count_to, select, find_rank

Definition at line 2532 of file bm.h.

◆ select()

template<class Alloc >
bool bm::bvector< Alloc >::select ( bm::id_t  rank,
bm::id_t pos,
const rs_index_type blocks_cnt 
) const

select bit-vector position for the specified rank(bitcount)

Rank based search, counts number of 1s from specified position until finds the ranked position relative to start from position. Uses In other words: range population count between from and pos == rank.

Parameters
rank- rank to find (bitcount)
pos- position with speciefied rank (relative to from position) [out]
blocks_cnt- block count structure to accelerate rank search
See also
running_count_blocks, find_rank
Returns
true if requested rank was found

Definition at line 3943 of file bm.h.

◆ set() [1/3]

template<class Alloc >
bvector< Alloc > & bm::bvector< Alloc >::set ( bm::id_t  n,
bool  val = true 
)

Sets bit n if val is true, clears bit n if val is false.

Parameters
n- index of the bit to be set
val- new bit value
Returns
*this

Definition at line 3367 of file bm.h.

Referenced by bvector_bulk_set_test(), bm::sparse_vector< unsigned, bm::bvector<> >::clear(), DemoOR(), fill_bvector(), generate_bvector(), bm::sparse_vector< unsigned, bm::bvector<> >::import(), main(), pick_benchmark_set(), and run_benchmark().

◆ set() [2/3]

template<class Alloc >
bvector< Alloc > & bm::bvector< Alloc >::set ( )

Sets every bit in this bitset to 1.

Returns
*this

Definition at line 3358 of file bm.h.

◆ set() [3/3]

template<class Alloc >
void bm::bvector< Alloc >::set ( const bm::id_t ids,
unsigned  ids_size,
bm::sort_order  so = bm::BM_UNKNOWN 
)

Set list of bits in this bitset to 1.

Method implements optimized bulk setting of multiple bits at once. The best results are achieved when the imput comes sorted. This is equivalent of OR (Set Union), argument set as an array.

Parameters
ids- pointer on array of indexes to set
ids_size- size of the input (ids)
so- sort order (use BM_SORTED for faster load)
See also
keep, clear

Definition at line 3290 of file bm.h.

◆ set_allocator_pool()

template<class Alloc>
void bm::bvector< Alloc >::set_allocator_pool ( allocator_pool_type pool_ptr)
inline

Set allocator pool for local (non-threaded) memory cyclic(lots of alloc-free ops) opertations.

Definition at line 1448 of file bm.h.

Referenced by bm::bvector< Alloc >::mem_pool_guard::assign_if_not_set(), bm::sparse_vector< unsigned, bm::bvector<> >::extract(), and bm::bvector< Alloc >::mem_pool_guard::mem_pool_guard().

◆ set_bit()

template<class Alloc >
bool bm::bvector< Alloc >::set_bit ( bm::id_t  n,
bool  val = true 
)

Sets bit n.

Parameters
n- index of the bit to be set.
val- new bit value
Returns
TRUE if bit was changed
Examples:
xsample01.cpp.

Definition at line 3406 of file bm.h.

Referenced by bv_set_bit_test(), fill_bvector(), and generate_random_vector().

◆ set_bit_and()

template<class Alloc >
bool bm::bvector< Alloc >::set_bit_and ( bm::id_t  n,
bool  val = true 
)

Sets bit n using bit AND with the provided value.

Parameters
n- index of the bit to be set.
val- new bit value
Returns
TRUE if bit was changed

Definition at line 3393 of file bm.h.

◆ set_bit_conditional()

template<class Alloc >
bool bm::bvector< Alloc >::set_bit_conditional ( bm::id_t  n,
bool  val,
bool  condition 
)

Sets bit n only if current value equals the condition.

Parameters
n- index of the bit to be set.
val- new bit value
condition- expected current value
Returns
TRUE if bit was changed

Definition at line 3376 of file bm.h.

◆ set_bit_no_check()

template<class Alloc >
void bm::bvector< Alloc >::set_bit_no_check ( bm::id_t  n)

◆ set_gap_levels()

template<typename Alloc >
void bm::bvector< Alloc >::set_gap_levels ( const gap_word_t glevel_len)

Sets new GAP lengths table. All GAP blocks will be reallocated to match the new scheme.

Parameters
glevel_len- pointer on C-style array keeping GAP block sizes.

Definition at line 3035 of file bm.h.

◆ set_new_blocks_strat()

template<class Alloc>
void bm::bvector< Alloc >::set_new_blocks_strat ( strategy  strat)
inline

Sets new blocks allocation strategy.

Parameters
strat- Strategy code 0 - bitblocks allocation only. 1 - Blocks mutation mode (adaptive algorithm)

Definition at line 2138 of file bm.h.

Referenced by main().

◆ set_range()

template<typename Alloc >
bvector< Alloc > & bm::bvector< Alloc >::set_range ( bm::id_t  left,
bm::id_t  right,
bool  value = true 
)

Sets all bits in the specified closed interval [left,right] Interval must be inside the bvector's size. This method DOES NOT resize vector.

Parameters
left- interval start
right- interval end (closed interval)
value- value to set interval in
Returns
*this

Definition at line 2431 of file bm.h.

Referenced by bv_count_and(), generate_bvector(), bm::sparse_vector< unsigned, bm::bvector<> >::import(), bm::sparse_vector< unsigned, bm::bvector<> >::join(), and bm::sparse_vector< unsigned, bm::bvector<> >::merge().

◆ shift_right()

template<class Alloc >
bool bm::bvector< Alloc >::shift_right ( )

Shift right by 1 bit, fill with zero return carry over.

Returns
Carry over bit value (1 or 0)

Definition at line 4136 of file bm.h.

Referenced by DNA_FingerprintScanner::Find().

◆ size()

template<class Alloc>
size_type bm::bvector< Alloc >::size ( ) const
inline

return current size of the vector (bits)

Definition at line 1657 of file bm.h.

Referenced by bm::bvector<>::operator=(), print_bvector(), and run_benchmark().

◆ swap()

template<typename Alloc>
void bm::bvector< Alloc >::swap ( bvector< Alloc > &  bvect)

Exchanges content of bv and this bvector.

Definition at line 3181 of file bm.h.

Referenced by main().

◆ sync_size()

template<typename Alloc >
void bm::bvector< Alloc >::sync_size ( )
protected

Syncronize size if it got extended due to bulk import.

Definition at line 2519 of file bm.h.

◆ test()

template<class Alloc>
bool bm::bvector< Alloc >::test ( bm::id_t  n) const
inline

returns true if bit n is set and false is bit n is 0.

Parameters
n- Index of the bit to check.
Returns
Bit value (1 or 0)

Definition at line 1788 of file bm.h.

Referenced by load_snp_report(), main(), and pick_benchmark_set().

◆ throw_bad_alloc()

template<class Alloc >
void bm::bvector< Alloc >::throw_bad_alloc ( )
static

Definition at line 6181 of file bm.h.

Friends And Related Function Documentation

◆ aggregator

template<class Alloc>
template<class BV >
friend class aggregator
friend

Definition at line 1233 of file bm.h.

◆ enumerator

template<class Alloc>
friend class enumerator
friend

Definition at line 1232 of file bm.h.

Referenced by bm::bvector<>::end(), and bm::bvector<>::get_enumerator().

◆ iterator_base

template<class Alloc>
friend class iterator_base
friend

Definition at line 1231 of file bm.h.


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