X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=libcds%2Fsrc%2Fstatic_sequence%2Fstatic_sequence_wvtree.cpp;h=5030fb185655bcd138366fabc78dddb070efcf63;hb=244e05181398ecc7f70dbadb7a4467727354d8c6;hp=1f6bb404cd40108622a6ea07e6419d4646b8856f;hpb=7aba0aca5c8989175fdefe5930c65b1d83606f11;p=SXSI%2FXMLTree.git diff --git a/libcds/src/static_sequence/static_sequence_wvtree.cpp b/libcds/src/static_sequence/static_sequence_wvtree.cpp index 1f6bb40..5030fb1 100644 --- a/libcds/src/static_sequence/static_sequence_wvtree.cpp +++ b/libcds/src/static_sequence/static_sequence_wvtree.cpp @@ -22,6 +22,7 @@ #include static_sequence_wvtree::static_sequence_wvtree(uint * symbols, uint n, wt_coder * c, static_bitsequence_builder * bmb, alphabet_mapper * am) { + this->n = n; for(uint i=0;imap(symbols[i]); this->am = am; @@ -34,6 +35,7 @@ static_sequence_wvtree::static_sequence_wvtree(uint * symbols, uint n, wt_coder } static_sequence_wvtree::static_sequence_wvtree(uchar * symbols, uint n, wt_coder * c, static_bitsequence_builder * bmb, alphabet_mapper * am) { + this->n = n; for(uint i=0;imap((uint)symbols[i]); this->am = am; @@ -66,7 +68,7 @@ uint static_sequence_wvtree::rank(uint symbol, uint pos) { uint static_sequence_wvtree::rankLessThan(uint &symbol, uint pos) { uint s = am->map(symbol); // std::cout << "lessthan..." << std::endl; - uint r = root->rankLessThan(s, pos, 0, c); + uint r = root->rankLessThan(s, pos); symbol = am->unmap(s); return r; } @@ -98,7 +100,7 @@ vector static_sequence_wvtree::access(uint i, uint j, uint min, uint max) vector static_sequence_wvtree::accessAll(uint i, uint j) { vector resultSet; - if (j > i) + if (j < i) return resultSet; resultSet.reserve(j-i+1); @@ -124,12 +126,17 @@ uint static_sequence_wvtree::size() { uint static_sequence_wvtree::save(FILE * fp) { uint wr = WVTREE_HDR; wr = fwrite(&wr,sizeof(uint),1,fp); + fflush(fp); if(wr!=1) return 1; wr = fwrite(&n,sizeof(uint),1,fp); + fflush(fp); if(wr!=1) return 1; if(c->save(fp)) return 1; + fflush(fp); if(am->save(fp)) return 1; + fflush(fp); if(root->save(fp)) return 1; + fflush(fp); return 0; }