112 for (
size_t i = 0; i < vect.size(); ++i)
114 if (vect[i] == value)
124 cout <<
"( count = " << bv.
count() <<
")" <<
": [";
127 for (; en.
valid(); ++en)
152 scanner.
find_eq(sv, 25, bv_found);
156 scanner.
invert(sv, bv_found);
161 std::vector<unsigned> vect;
170 unsigned search_repeats = 500;
174 std::vector<unsigned> search_vect;
177 search_vect.reserve(search_repeats);
178 for (
unsigned i = 0; i < search_repeats;)
181 if (!bv_tmp.
test(idx))
183 search_vect.push_back(idx);
197 bm::chrono_taker tt1(
"1. std::vector<> scan ", search_repeats, &timing_map);
199 for (
unsigned i = 0; i < search_repeats; ++i)
201 unsigned vs = search_vect[i];
207 bm::chrono_taker tt1(
"2. sparse_vector<> scan ", search_repeats, &timing_map);
210 scanner.
find_eq(sv, search_vect.
begin(), search_vect.end(), bv_res2);
214 if (bv_res1.
compare(bv_res2) != 0)
216 std::cerr <<
"2. Search result mismatch!" << std::endl;
222 bm::chrono_taker tt1(
"3. sparse_vector<>::const_iterator search ", search_repeats, &timing_map);
230 for (; it != it_end; ++it)
233 if (bv_search.
test(v))
241 if (bv_res1.
compare(bv_res3) != 0)
243 std::cerr <<
"3. Search result mismatch!" << std::endl;
250 catch(std::exception& ex)
252 std::cerr << ex.what() << std::endl;
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
bvector< Alloc > & reset()
Clears every bit in the bitvector.
void find_eq(const SV &sv, typename SV::value_type value, typename SV::bvector_type &bv_out)
find all sparse vector elements EQ to search value
static void generate_test_set(std::vector< unsigned > &vect, bm::bvector<> &bv_null, sparse_vector_u32 &sv)
friend back_insert_iterator
bm::chrono_taker::duration_map_type timing_map
void invert(const SV &sv, typename SV::bvector_type &bv_out)
invert search result ("EQ" to "not EQ")
Sparse constainer sparse_vector<> for integer types using bit-transposition transform.
Timing utilities for benchmarking (internal)
algorithms for sparse_vector scan/seach
void combine_or(BV &bv, It first, It last)
OR Combine bitvector and the iterable sequence.
void set(size_type idx, value_type v)
set specified element with bounds checking and automatic resize
int compare(const bvector< Alloc > &bvect) const
Lexicographical comparison with a bitvector.
sparse vector with runtime compression using bit transposition method
enumerator first() const
Returns enumerator pointing on the first non-zero bit.
static void vector_search(const std::vector< unsigned > &vect, const bm::bvector<> &bv_null, unsigned value, bm::bvector<> &bv_res)
const_iterator begin() const
Provide const iterator access to container content.
support "non-assigned" or "NULL" logic
std::map< std::string, statistics > duration_map_type
test name to duration map
void print_bvector(const bm::bvector<> &bv)
static void print_duration_map(const duration_map_type &dmap, format fmt=ct_time)
size_type count() const
population cout (count of ON bits)
void init()
Explicit post-construction initialization.
back_insert_iterator get_back_inserter()
Provide back insert iterator Back insert iterator implements buffered insertion, which is faster...
bool valid() const
Checks if iterator is still valid.
enumerator end() const
Returns enumerator pointing on the next bit after the last.
Utility class to collect performance measurements and statistics.
bm::sparse_vector< bm::id_t, bm::bvector<> > sparse_vector_u32
std::uniform_int_distribution rand_dis(1, value_max)
bool test(size_type n) const
returns true if bit n is set and false is bit n is 0.
Constant iterator designed to enumerate "ON" bits.
std::mt19937 gen(rand_dev())
std::random_device rand_dev
const_iterator end() const
Provide const iterator access to the end.
void set_bit_no_check(size_type n)
Set bit without checking preconditions (size, etc)
Algorithms for sparse_vector<>