X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=libcds%2Ftests%2Fstatic_bitsequence_tester.cpp;h=509107decaf556ea05ceca5cc4bd67dd2ebc6e7f;hb=44dc45dfa812b495fc4ef7dff7f69a6b89ee5128;hp=bd801ed5455da24a2302b2e7ea1c02f4b07abc19;hpb=f1065079810ebe519367f7399edb68307c789b41;p=SXSI%2FXMLTree.git diff --git a/libcds/tests/static_bitsequence_tester.cpp b/libcds/tests/static_bitsequence_tester.cpp index bd801ed..509107d 100644 --- a/libcds/tests/static_bitsequence_tester.cpp +++ b/libcds/tests/static_bitsequence_tester.cpp @@ -65,6 +65,7 @@ void load(char *fname, uint ** text, uint * n) { void test_bitsequence(uint * bitseq, uint len, static_bitsequence * bs) { uint ones = 0; + uint last_one = 0; bool error = false; for(uint i=0;ilength()/10))==0) { cout << endl; cout.flush(); } } - if(bitget(bitseq,i)) ones++; + if(bitget(bitseq,i)) { + for(uint k=last_one; !error && kselect_next1(k)!=i) { + uint ans= bs->select_next1(k); + cout << "Error select_next1" << endl; + cout << " got: (k=" << k << ") " << ans << " expected: " << i << endl; + cout << " rank(" << k << ")=" << bs->rank1(k) << " access(" << k << ")=" << bs->access(k) << endl; + cout << " rank(" << ans << ")=" << bs->rank1(ans) << " access(" << ans << ")=" << bs->access(ans) << endl; + error = true; + } + } + last_one = i; + ones++; + } if(bs->access(i) != (bitget(bitseq,i)!=0)) { cout << "Access error for position " << i << endl; cout << " got: " << bs->access(i) << " expected: " << (bitget(bitseq,i)!=0) << endl; @@ -178,3 +192,18 @@ void speed_select1(static_bitsequence * ss, uint * bitseq, uint n) { cout << " * Time per select1: " << 1000*t/NQUERIES << " msecs" << endl; cout << " - Check sum: " << acc << endl; } + +void speed_selectnext1(static_bitsequence * ss, uint * bitseq, uint n) { + uint acc=0; + srand(SEED); + + start_clock(); + for(uint i=0;iselect_next1(pos); + } + double t = stop_clock(); + cout << " * Time for " << NQUERIES << " select_next1s: " << t << " secs" << endl; + cout << " * Time per select_next1: " << 1000*t/NQUERIES << " msecs" << endl; + cout << " - Check sum: " << acc << endl; +}