Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals | Examples

bm::bvector< Alloc, MS > Class Template Reference
[The Main bvector<> Group]

bitvector with runtime compression of bits. More...

#include <bm.h>


Public Types

typedef Alloc allocator_type
typedef blocks_manager< Alloc,
MS > 
blocks_manager_type
typedef bm::id_t size_type
 Type used to count bits in the bit vector.
typedef bool const_reference
enum  optmode { opt_free_0 = 1, opt_free_01 = 2, opt_compress = 3 }
 Optimization mode Every next level means additional checks (better compression vs time). More...

Public Member Functions

 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.
 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.
 bvector (const bvector< Alloc, MS > &bvect)
bvectoroperator= (const bvector< Alloc, MS > &bvect)
reference operator[] (bm::id_t n)
bool operator[] (bm::id_t n) const
void operator &= (const bvector< Alloc, MS > &bvect)
void operator^= (const bvector< Alloc, MS > &bvect)
void operator|= (const bvector< Alloc, MS > &bvect)
void operator-= (const bvector< Alloc, MS > &bvect)
bool operator< (const bvector< Alloc, MS > &bvect) const
bool operator<= (const bvector< Alloc, MS > &bvect) const
bool operator> (const bvector< Alloc, MS > &bvect) const
bool operator>= (const bvector< Alloc, MS > &bvect) const
bool operator== (const bvector< Alloc, MS > &bvect) const
bool operator!= (const bvector< Alloc, MS > &bvect) const
bvector< Alloc, MS > operator~ () const
Alloc get_allocator () const
bool set_bit (bm::id_t n, bool val=true)
 Sets bit n.
bvector< Alloc, MS > & set (bm::id_t n, bool val=true)
 Sets bit n if val is true, clears bit n if val is false.
bvector< Alloc, MS > & set ()
 Sets every bit in this bitset to 1.
bvector< Alloc, MS > & 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.
insert_iterator inserter ()
void clear_bit (bm::id_t n)
 Clears bit n.
void clear (bool free_mem=false)
 Clears every bit in the bitvector.
bvector< Alloc, MS > & reset ()
 Clears every bit in the bitvector.
bm::id_t count () const
 Returns count of bits which are 1.
size_type capacity () const
 Returns bvector's capacity (number of bits it can store).
size_type size () const
 return current size of the vector (bits)
void resize (size_type new_size)
 Change size of the bvector.
unsigned count_blocks (unsigned *arr) const
 Computes bitcount values for all bvector blocks.
bm::id_t count_range (bm::id_t left, bm::id_t right, unsigned *block_count_arr=0) const
 Returns count of 1 bits in the given diapason.
bm::id_t recalc_count ()
void forget_count ()
bvector< Alloc, MS > & invert ()
 Inverts all bits.
bool get_bit (bm::id_t n) const
 returns true if bit n is set and false is bit n is 0.
bool test (bm::id_t n) const
 returns true if bit n is set and false is bit n is 0.
bool any () const
 Returns true if any bits in this bitset are set, and otherwise returns false.
bool none () const
 Returns true if no bits are set, otherwise returns false.
bvector< Alloc, MS > & flip (bm::id_t n)
 Flips bit n.
bvector< Alloc, MS > & flip ()
 Flips all bits.
void swap (bvector< Alloc, MS > &bv)
 Exchanges content of bv and this bitvector.
bm::id_t get_first () const
 Gets number of first bit which is ON.
bm::id_t get_next (bm::id_t prev) const
 Finds the number of the next bit ON.
bm::id_t extract_next (bm::id_t prev)
void calc_stat (struct statistics *st) const
 Calculates bitvector statistics.
bm::bvector< Alloc, MS > & bit_or (const bm::bvector< Alloc, MS > &vect)
 Logical OR operation.
bm::bvector< Alloc, MS > & bit_and (const bm::bvector< Alloc, MS > &vect)
 Logical AND operation.
bm::bvector< Alloc, MS > & bit_xor (const bm::bvector< Alloc, MS > &vect)
 Logical XOR operation.
bm::bvector< Alloc, MS > & bit_sub (const bm::bvector< Alloc, MS > &vect)
 Logical SUB operation.
void set_new_blocks_strat (strategy strat)
 Sets new blocks allocation strategy.
strategy get_new_blocks_strat () const
 Returns blocks allocation strategy.
void stat (unsigned blocks=0) const
void optimize (bm::word_t *temp_block=0, optmode opt_mode=opt_compress)
 Optimize memory bitvector's memory allocation.
void optimize_gap_size ()
 Optimize sizes of GAP blocks.
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.
int compare (const bvector< Alloc, MS > &bvect) const
 Lexicographical comparison with a bitvector.
bm::word_tallocate_tempblock () const
 Allocates temporary block of memory.
void free_tempblock (bm::word_t *block) const
 Frees temporary block of memory.
enumerator first () const
 Returns enumerator pointing on the first non-zero bit.
enumerator end () const
 Returns enumerator pointing on the next bit after the last.
const bm::word_tget_block (unsigned nb) const
void combine_operation_with_block (unsigned nb, const bm::word_t *arg_blk, int arg_gap, bm::operation opcode)
const blocks_manager_typeget_blocks_manager () const
blocks_manager_typeget_blocks_manager ()

Friends

class iterator_base
class enumerator

Data Structures

class  counted_enumerator
 Constant input 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 input 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  reference
 Class reference implements an object for bit assignment. Since C++ does not provide with build-in bit type supporting l-value operations we have to emulate it. More...
struct  statistics
 Structure with statistical information about bitset's memory allocation details. More...


Detailed Description

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

bitvector with runtime compression of bits.
Examples:

sample1.cpp, sample2.cpp, sample3.cpp, sample4.cpp, sample5.cpp, sample6.cpp, sample7.cpp, sample8.cpp, and sample9.cpp.

Definition at line 107 of file bm.h.


Member Typedef Documentation

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

Definition at line 111 of file bm.h.

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

Definition at line 112 of file bm.h.

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

Definition at line 229 of file bm.h.

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

Type used to count bits in the bit vector.

Definition at line 114 of file bm.h.


Member Enumeration Documentation

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

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

See also:
optimize
Enumeration values:
opt_free_0  Free unused 0 blocks.
opt_free_01  Free unused 0 and 1 blocks.
opt_compress  compress blocks when possible

Definition at line 1317 of file bm.h.


Constructor & Destructor Documentation

template<class Alloc, class MS>
bm::bvector< Alloc, MS >::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.
See also:
bm::gap_len_table bm::gap_len_table_min set_new_blocks_strat

Definition at line 840 of file bm.h.

template<class Alloc, class MS>
bm::bvector< Alloc, MS >::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 852 of file bm.h.

template<class Alloc, class MS>
bm::bvector< Alloc, MS >::bvector const bvector< Alloc, MS > &  bvect  )  [inline]
 

Definition at line 862 of file bm.h.


Member Function Documentation

template<class Alloc, class MS>
bm::word_t* bm::bvector< Alloc, MS >::allocate_tempblock  )  const [inline]
 

Allocates temporary block of memory.

Temp block can be passed to bvector functions requiring some temp memory for their operation. (like serialize)

Note:
method is marked const, but it's not quite true, since it can in some cases modify the state of the block allocator (if it has a state). (Can be important in MT programs).
See also:
free_tempblock

Definition at line 1374 of file bm.h.

template<class Alloc, class MS>
bool bm::bvector< Alloc, MS >::any  )  const [inline]
 

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

Returns:
true if any bit is set

Definition at line 1149 of file bm.h.

References bm::for_each_nzblock_if().

Referenced by bm::bvector< Alloc, MS >::none().

template<class Alloc, class MS>
bm::bvector<Alloc, MS>& bm::bvector< Alloc, MS >::bit_and const bm::bvector< Alloc, MS > &  vect  )  [inline]
 

Logical AND operation.

Parameters:
vect - Argument vector.

Definition at line 1259 of file bm.h.

References bm::BM_AND, and BMCOUNT_VALID.

Referenced by bm::operator &(), and bm::bvector< Alloc, MS >::operator &=().

template<class Alloc, class MS>
bm::bvector<Alloc, MS>& bm::bvector< Alloc, MS >::bit_or const bm::bvector< Alloc, MS > &  vect  )  [inline]
 

Logical OR operation.

Parameters:
vect - Argument vector.

Definition at line 1248 of file bm.h.

References bm::BM_OR, and BMCOUNT_VALID.

Referenced by bm::bvector< Alloc, MS >::operator=(), bm::operator|(), and bm::bvector< Alloc, MS >::operator|=().

template<class Alloc, class MS>
bm::bvector<Alloc, MS>& bm::bvector< Alloc, MS >::bit_sub const bm::bvector< Alloc, MS > &  vect  )  [inline]
 

Logical SUB operation.

Parameters:
vect - Argument vector.

Definition at line 1281 of file bm.h.

References bm::BM_SUB, and BMCOUNT_VALID.

Referenced by bm::operator-(), and bm::bvector< Alloc, MS >::operator-=().

template<class Alloc, class MS>
bm::bvector<Alloc, MS>& bm::bvector< Alloc, MS >::bit_xor const bm::bvector< Alloc, MS > &  vect  )  [inline]
 

Logical XOR operation.

Parameters:
vect - Argument vector.

Definition at line 1270 of file bm.h.

References bm::BM_XOR, and BMCOUNT_VALID.

Referenced by bm::operator^(), and bm::bvector< Alloc, MS >::operator^=().

template<class Alloc, class MS>
void bm::bvector< Alloc, MS >::calc_stat struct 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:
sample7.cpp.

Referenced by CreateSets(), FillSets(), bm::bvector< Alloc, MS >::optimize_gap_size(), and serialize_bvector().

template<class Alloc, class MS>
size_type bm::bvector< Alloc, MS >::capacity  )  const [inline]
 

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

Definition at line 1056 of file bm.h.

template<class Alloc, class MS>
void bm::bvector< Alloc, MS >::clear bool  free_mem = false  )  [inline]
 

Clears every bit in the bitvector.

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

Definition at line 1030 of file bm.h.

References BMCOUNT_SET.

Referenced by main(), bm::bvector< Alloc, MS >::operator=(), and bm::bvector< Alloc, MS >::reset().

template<class Alloc, class MS>
void bm::bvector< Alloc, MS >::clear_bit bm::id_t  n  )  [inline]
 

Clears bit n.

Parameters:
n - bit's index to be cleaned.

Definition at line 1018 of file bm.h.

References bm::bvector< Alloc, MS >::set().

template<class Alloc, class MS>
void bm::bvector< Alloc, MS >::combine_operation_with_block unsigned  nb,
const bm::word_t arg_blk,
int  arg_gap,
bm::operation  opcode
[inline]
 

Definition at line 1446 of file bm.h.

References BM_IS_GAP, and bm::bvector< Alloc, MS >::get_block().

template<typename Alloc, typename MS>
int bm::bvector< Alloc, MS >::compare const bvector< Alloc, MS > &  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.

Definition at line 1845 of file bm.h.

References bm::bit_is_all_zero(), bm::bitcmp(), bm::bvector< Alloc, MS >::blockman_, BM_IS_GAP, BMGAP_PTR, bm::gap_convert_to_bitset(), bm::gap_is_all_zero(), and bm::gapcmp().

Referenced by main(), bm::bvector< Alloc, MS >::operator!=(), bm::bvector< Alloc, MS >::operator<(), bm::bvector< Alloc, MS >::operator<=(), bm::bvector< Alloc, MS >::operator==(), bm::bvector< Alloc, MS >::operator>(), and bm::bvector< Alloc, MS >::operator>=().

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

Returns count of bits which are 1.

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

Definition at line 1603 of file bm.h.

References BMCOUNT_SET, and bm::for_each_nzblock().

Referenced by bm::bvector< Alloc, MS >::count_range(), main(), OrSets(), bm::bvector< Alloc, MS >::recalc_count(), serialize_bvector(), and bm::bvector< Alloc, MS >::stat().

template<class Alloc, class MS>
unsigned bm::bvector< Alloc, MS >::count_blocks unsigned *  arr  )  const [inline]
 

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 1081 of file bm.h.

References bm::for_each_nzblock().

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

Returns count of 1 bits in the given diapason.

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:
Total number of bits ON.

Definition at line 1638 of file bm.h.

References bm::bit_block_calc_count_range(), BM_ASSERT, BM_IS_GAP, BMGAP_PTR, bm::bvector< Alloc, MS >::count(), bm::gap_bit_count_range(), and bm::bvector< Alloc, MS >::get_block().

template<class Alloc, class MS>
bvector::enumerator bm::bvector< Alloc, MS >::end  )  const [inline]
 

Returns enumerator pointing on the next bit after the last.

Examples:
sample7.cpp.

Definition at line 1409 of file bm.h.

Referenced by EnumerateSets(), and main().

template<class Alloc, class MS>
bm::id_t bm::bvector< Alloc, MS >::extract_next bm::id_t  prev  )  [inline]
 

Definition at line 1225 of file bm.h.

template<class Alloc, class MS>
enumerator bm::bvector< Alloc, MS >::first  )  const [inline]
 

Returns enumerator pointing on the first non-zero bit.

Examples:
sample7.cpp.

Definition at line 1399 of file bm.h.

Referenced by EnumerateSets(), and main().

template<class Alloc, class MS>
bvector<Alloc, MS>& bm::bvector< Alloc, MS >::flip  )  [inline]
 

Flips all bits.

Returns:
*this

Definition at line 1184 of file bm.h.

References bm::bvector< Alloc, MS >::invert().

template<class Alloc, class MS>
bvector<Alloc, MS>& bm::bvector< Alloc, MS >::flip bm::id_t  n  )  [inline]
 

Flips bit n.

Returns:
*this

Definition at line 1174 of file bm.h.

References bm::bvector< Alloc, MS >::get_bit(), and bm::bvector< Alloc, MS >::set().

template<class Alloc, class MS>
void bm::bvector< Alloc, MS >::forget_count  )  [inline]
 

Disables count cache. Next call to count() or recalc_count() restores count caching.

Note:
Works only if BMCOUNTOPT enabled(defined). Othewise does nothing.

Definition at line 1117 of file bm.h.

References BMCOUNT_VALID.

template<class Alloc, class MS>
void bm::bvector< Alloc, MS >::free_tempblock bm::word_t block  )  const [inline]
 

Frees temporary block of memory.

Note:
method is marked const, but it's not quite true, since it can in some cases modify the state of the block allocator (if it has a state). (Can be important in MT programs).
See also:
allocate_tempblock

Definition at line 1389 of file bm.h.

template<class Alloc, class MS>
Alloc bm::bvector< Alloc, MS >::get_allocator  )  const [inline]
 

Definition at line 946 of file bm.h.

template<typename Alloc, typename MS>
bool bm::bvector< Alloc, MS >::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 1756 of file bm.h.

References BM_ASSERT, BM_IS_GAP, BMGAP_PTR, bm::gap_test(), and bm::bvector< Alloc, MS >::get_block().

Referenced by bm::bvector< Alloc, MS >::flip(), bm::bvector< Alloc, MS >::operator[](), and bm::bvector< Alloc, MS >::test().

template<class Alloc, class MS>
const bm::word_t* bm::bvector< Alloc, MS >::get_block unsigned  nb  )  const [inline]
 

Definition at line 1416 of file bm.h.

Referenced by bm::bvector< Alloc, MS >::combine_operation_with_block(), bm::bvector< Alloc, MS >::count_range(), bm::bvector< Alloc, MS >::get_bit(), and bm::bvector< Alloc, MS >::stat().

template<class Alloc, class MS>
blocks_manager_type& bm::bvector< Alloc, MS >::get_blocks_manager  )  [inline]
 

Definition at line 1490 of file bm.h.

template<class Alloc, class MS>
const blocks_manager_type& bm::bvector< Alloc, MS >::get_blocks_manager  )  const [inline]
 

Definition at line 1485 of file bm.h.

template<class Alloc, class MS>
bm::id_t bm::bvector< Alloc, MS >::get_first  )  const [inline]
 

Gets number of first bit which is ON.

Returns:
Index of the first 1 bit.
See also:
get_next

Definition at line 1211 of file bm.h.

Referenced by main().

template<class Alloc, class MS>
strategy bm::bvector< Alloc, MS >::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 1305 of file bm.h.

template<class Alloc, class MS>
bm::id_t bm::bvector< Alloc, MS >::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

Definition at line 1220 of file bm.h.

Referenced by main().

template<class Alloc, class MS>
insert_iterator bm::bvector< Alloc, MS >::inserter  )  [inline]
 

Function erturns insert iterator for this bitvector

Definition at line 1008 of file bm.h.

Referenced by main().

template<typename Alloc, typename MS>
bvector< Alloc, MS > & bm::bvector< Alloc, MS >::invert  ) 
 

Inverts all bits.

Definition at line 1732 of file bm.h.

References BM_SET_MMX_GUARD, BMCOUNT_VALID, and bm::for_each_block().

Referenced by bm::bvector< Alloc, MS >::flip().

template<class Alloc, class MS>
bool bm::bvector< Alloc, MS >::none  )  const [inline]
 

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

Definition at line 1165 of file bm.h.

References bm::bvector< Alloc, MS >::any().

template<class Alloc, class MS>
void bm::bvector< Alloc, MS >::operator &= const bvector< Alloc, MS > &  bvect  )  [inline]
 

Definition at line 891 of file bm.h.

References bm::bvector< Alloc, MS >::bit_and().

template<class Alloc, class MS>
bool bm::bvector< Alloc, MS >::operator!= const bvector< Alloc, MS > &  bvect  )  const [inline]
 

Definition at line 936 of file bm.h.

References bm::bvector< Alloc, MS >::compare().

template<class Alloc, class MS>
void bm::bvector< Alloc, MS >::operator-= const bvector< Alloc, MS > &  bvect  )  [inline]
 

Definition at line 906 of file bm.h.

References bm::bvector< Alloc, MS >::bit_sub().

template<class Alloc, class MS>
bool bm::bvector< Alloc, MS >::operator< const bvector< Alloc, MS > &  bvect  )  const [inline]
 

Definition at line 911 of file bm.h.

References bm::bvector< Alloc, MS >::compare().

template<class Alloc, class MS>
bool bm::bvector< Alloc, MS >::operator<= const bvector< Alloc, MS > &  bvect  )  const [inline]
 

Definition at line 916 of file bm.h.

References bm::bvector< Alloc, MS >::compare().

template<class Alloc, class MS>
bvector& bm::bvector< Alloc, MS >::operator= const bvector< Alloc, MS > &  bvect  )  [inline]
 

Definition at line 870 of file bm.h.

References bm::bvector< Alloc, MS >::bit_or(), bm::bvector< Alloc, MS >::clear(), and bm::bvector< Alloc, MS >::resize().

template<class Alloc, class MS>
bool bm::bvector< Alloc, MS >::operator== const bvector< Alloc, MS > &  bvect  )  const [inline]
 

Definition at line 931 of file bm.h.

References bm::bvector< Alloc, MS >::compare().

template<class Alloc, class MS>
bool bm::bvector< Alloc, MS >::operator> const bvector< Alloc, MS > &  bvect  )  const [inline]
 

Definition at line 921 of file bm.h.

References bm::bvector< Alloc, MS >::compare().

template<class Alloc, class MS>
bool bm::bvector< Alloc, MS >::operator>= const bvector< Alloc, MS > &  bvect  )  const [inline]
 

Definition at line 926 of file bm.h.

References bm::bvector< Alloc, MS >::compare().

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

Definition at line 885 of file bm.h.

References BM_ASSERT, and bm::bvector< Alloc, MS >::get_bit().

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

Definition at line 878 of file bm.h.

References BM_ASSERT.

template<class Alloc, class MS>
void bm::bvector< Alloc, MS >::operator^= const bvector< Alloc, MS > &  bvect  )  [inline]
 

Definition at line 896 of file bm.h.

References bm::bvector< Alloc, MS >::bit_xor().

template<class Alloc, class MS>
void bm::bvector< Alloc, MS >::operator|= const bvector< Alloc, MS > &  bvect  )  [inline]
 

Definition at line 901 of file bm.h.

References bm::bvector< Alloc, MS >::bit_or().

template<class Alloc, class MS>
bvector<Alloc, MS> bm::bvector< Alloc, MS >::operator~  )  const [inline]
 

Definition at line 941 of file bm.h.

template<typename Alloc, typename MS>
void bm::bvector< Alloc, MS >::optimize bm::word_t temp_block = 0,
optmode  opt_mode = opt_compress
 

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.

See also:
optmode, optimize_gap_size

Definition at line 1790 of file bm.h.

References bm::for_each_nzblock().

Referenced by main(), and serialize_bvector().

template<typename Alloc, typename MS>
void bm::bvector< Alloc, MS >::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 1808 of file bm.h.

References bm::bvector< Alloc, MS >::calc_stat(), bm::gap_levels, bm::improve_gap_levels(), and bm::bvector< Alloc, MS >::set_gap_levels().

template<class Alloc, class MS>
bm::id_t bm::bvector< Alloc, MS >::recalc_count  )  [inline]
 

Definition at line 1104 of file bm.h.

References BMCOUNT_VALID, and bm::bvector< Alloc, MS >::count().

template<class Alloc, class MS>
bvector<Alloc, MS>& bm::bvector< Alloc, MS >::reset  )  [inline]
 

Clears every bit in the bitvector.

Returns:
*this;

Definition at line 1040 of file bm.h.

References bm::bvector< Alloc, MS >::clear().

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

Change size of the bvector.

Parameters:
new_size - new size in bits

Definition at line 1620 of file bm.h.

References bm::bvector< Alloc, MS >::set_range().

Referenced by main(), and bm::bvector< Alloc, MS >::operator=().

template<class Alloc, class MS>
bvector<Alloc, MS>& bm::bvector< Alloc, MS >::set  )  [inline]
 

Sets every bit in this bitset to 1.

Returns:
*this

Definition at line 983 of file bm.h.

References BMCOUNT_VALID, and bm::bvector< Alloc, MS >::set_range().

Referenced by bm::bvector< Alloc, MS >::clear_bit(), and bm::bvector< Alloc, MS >::flip().

template<class Alloc, class MS>
bvector<Alloc, MS>& bm::bvector< Alloc, MS >::set bm::id_t  n,
bool  val = true
[inline]
 

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 971 of file bm.h.

References bm::bvector< Alloc, MS >::set_bit().

Referenced by main().

template<class Alloc, class MS>
bool bm::bvector< Alloc, MS >::set_bit bm::id_t  n,
bool  val = true
[inline]
 

Sets bit n.

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

Definition at line 958 of file bm.h.

References BM_ASSERT.

Referenced by bm::bvector< Alloc, MS >::set().

template<typename Alloc, typename MS>
void bm::bvector< Alloc, MS >::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 1829 of file bm.h.

References bm::for_each_nzblock(), and bm::bvector< Alloc, MS >::set_gap_levels().

Referenced by bm::bvector< Alloc, MS >::optimize_gap_size(), and bm::bvector< Alloc, MS >::set_gap_levels().

template<class Alloc, class MS>
void bm::bvector< Alloc, MS >::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 1294 of file bm.h.

Referenced by main().

template<typename Alloc, typename MS>
bvector< Alloc, MS > & bm::bvector< Alloc, MS >::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 1580 of file bm.h.

References BM_ASSERT, BM_SET_MMX_GUARD, and BMCOUNT_VALID.

Referenced by bm::bvector< Alloc, MS >::resize(), and bm::bvector< Alloc, MS >::set().

template<class Alloc, class MS>
size_type bm::bvector< Alloc, MS >::size  )  const [inline]
 

return current size of the vector (bits)

Definition at line 1064 of file bm.h.

template<class Alloc, class MS>
void bm::bvector< Alloc, MS >::stat unsigned  blocks = 0  )  const
 

Definition at line 2132 of file bm.h.

References bm::bit_block_calc_count(), BMGAP_PTR, bm::bvector< Alloc, MS >::count(), bm::gap_bit_count(), bm::gap_control_sum(), bm::gap_length(), bm::gap_level(), bm::bvector< Alloc, MS >::get_block(), and IS_FULL_BLOCK.

template<class Alloc, class MS>
void bm::bvector< Alloc, MS >::swap bvector< Alloc, MS > &  bv  )  [inline]
 

Exchanges content of bv and this bitvector.

Definition at line 1191 of file bm.h.

References BMCOUNT_VALID, and bm::xor_swap().

template<class Alloc, class MS>
bool bm::bvector< Alloc, MS >::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 1140 of file bm.h.

References bm::bvector< Alloc, MS >::get_bit().


Friends And Related Function Documentation

template<class Alloc, class MS>
friend class enumerator [friend]
 

Definition at line 785 of file bm.h.

template<class Alloc, class MS>
friend class iterator_base [friend]
 

Definition at line 784 of file bm.h.


The documentation for this class was generated from the following file:
Generated on Thu Apr 20 13:29:13 2006 for BitMagic by  doxygen 1.4.1