X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=libcds%2Fsrc%2Fstatic_sequence%2Fstatic_sequence_gmr.cpp;h=9203171dbe4e1915165b24daafcfcdebc88e7d8e;hb=6a9117a97674437c9fe00b099c40ccb61d45d704;hp=ead7748ce9023799a720e1f42a0f11ee05862b09;hpb=d628f321b023cfff0c92154de6997fe655dc11aa;p=SXSI%2FXMLTree.git diff --git a/libcds/src/static_sequence/static_sequence_gmr.cpp b/libcds/src/static_sequence/static_sequence_gmr.cpp index ead7748..9203171 100644 --- a/libcds/src/static_sequence/static_sequence_gmr.cpp +++ b/libcds/src/static_sequence/static_sequence_gmr.cpp @@ -27,7 +27,7 @@ static_sequence_gmr::static_sequence_gmr(uint * sequence, uint n, uint chunk_len uint * new_seq = new uint[len]; sigma = 0; for(uint i=0;iselect0(bp); uint prev = rank_pos-bp+1; uint sum = B->rank1(B->select0(bp+i)) - prev; uint cr = chunk[i]->rank(c,j-i*chunk_length); + /*if(c==0) { + cout << "c=" << c << " j=" << j << endl; + cout << "i=" << i << endl; + cout << "bp=" << bp << endl; + cout << "rank_pos=" << rank_pos << endl; + cout << "prev=" << prev << endl; + cout << "sum=" << sum << endl; + cout << "cr=" << cr << endl; + }*/ return sum + cr; } uint static_sequence_gmr::select(uint c, uint j) { -// c++; + c++; uint rank_pos = B->select0(c*(len/chunk_length)); uint prev = B->rank1(rank_pos); uint sel = prev+j; @@ -115,12 +124,25 @@ uint static_sequence_gmr::select(uint c, uint j) { uint desp = B->rank1(B->select0((i)))-prev; if (desp+1==0) desp=0; uint rchunk = i%(len/chunk_length); + /*if(j==90) { + cout << "------------------------------" << endl; + cout << "c=" << c << " j=" << j << endl; + cout << "chunk_length=" << chunk_length << endl; + cout << "rank_pos=" << rank_pos << endl; + cout << "prev=" << prev << endl; + cout << "sel=" << sel << endl; + cout << "block=" << block << endl; + cout << "i=" << i << endl; + cout << "desp=" << desp << endl; + cout << "rchunk=" << rchunk << endl; + cout << "j-desp=" << j-desp << endl; + }*/ return (rchunk*chunk_length)+chunk[rchunk]->select(c, j-desp); } uint static_sequence_gmr::access(uint j) { - return chunk[j/chunk_length]->access(j%chunk_length); + return chunk[j/chunk_length]->access(j%chunk_length)-1; }