BitMagicC++Library
Public Member Functions
bm::random_subset< BV > Class Template Reference

#include <bmrandom.h>

Public Member Functions

 random_subset ()
 
 ~random_subset ()
 
void sample (BV &bv_out, const BV &bv_in, unsigned count)
 Get random subset of input vector. More...
 

Detailed Description

template<class BV>
class bm::random_subset< BV >

Class implements algorithm for random subset generation.

Implemented method tries to be fair, but doesn't guarantee true randomeness.

Performace note: Class holds temporary buffers and variables, so it is recommended to re-use instances over multiple calls.

Examples:
sample10.cpp.

Definition at line 45 of file bmrandom.h.

Constructor & Destructor Documentation

◆ random_subset()

template<class BV >
bm::random_subset< BV >::random_subset ( )

Definition at line 107 of file bmrandom.h.

◆ ~random_subset()

template<class BV >
bm::random_subset< BV >::~random_subset ( )

Definition at line 117 of file bmrandom.h.

Member Function Documentation

◆ sample()

template<class BV >
void bm::random_subset< BV >::sample ( BV &  bv_out,
const BV &  bv_in,
unsigned  count 
)

Get random subset of input vector.

Parameters
bv_out- destination vector
bv_in- input vector
count- number of bits to pick

Definition at line 126 of file bmrandom.h.

References bm::bit_block_copy(), bm::bit_block_set(), bm::bit_convert_to_arr(), bm::bit_list(), bm::bit_list_4(), BM_ASSERT, BM_IS_GAP, BMGAP_PTR, bm::gap_convert_to_arr(), bm::gap_convert_to_bitset(), bm::gap_max_bits, bm::set_bit(), bm::set_block_size, and bm::word_bitcount().

Referenced by main().


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