Example of how to get random subset of a bit-vector
- See also
- bm::random_subset
#include <iostream>
using namespace std;
{
if (first == last)
cout << "<EMPTY SET>";
else
for(;first != last; ++first)
cout << *first << ";";
cout << endl;
}
{
try
{
for (i = 0; i < 30000; i+=10)
{
}
for (i = 300000; i < 400000; i+=100)
{
}
rand_sampler.
sample(bvsubset1, bv, 20);
rand_sampler.
sample(bvsubset2, bv, 20);
cout << endl;
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
Generation of random subset.
pre-processor un-defines to avoid global space pollution (internal)
Bitvector Bit-vector container with runtime compression of bits.
bvector< Alloc > & set(size_type n, bool val=true)
Sets bit n if val is true, clears bit n if val is false.
bvector_size_type size_type
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.
void sample(BV &bv_out, const BV &bv_in, size_type sample_count)
Get random subset of input vector.
void PrintContainer(T first, T last)