X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=libcds%2Fsrc%2Fstatic_sequence%2Fstatic_sequence_wvtree.cpp;h=e86da89c261e67a27515e04e1b58b6c7bc92af21;hb=0412eaf977e4ef67f68db6ded4f1cee0e12cee4f;hp=ea6a8131358f4045ed549ba609940a9772a8eb55;hpb=a9846746dc7a55764591fcc273fd48c6049df962;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 ea6a813..e86da89 100644 --- a/libcds/src/static_sequence/static_sequence_wvtree.cpp +++ b/libcds/src/static_sequence/static_sequence_wvtree.cpp @@ -33,6 +33,19 @@ static_sequence_wvtree::static_sequence_wvtree(uint * symbols, uint n, wt_coder symbols[i] = am->unmap(symbols[i]); } +static_sequence_wvtree::static_sequence_wvtree(uchar * symbols, uint n, wt_coder * c, static_bitsequence_builder * bmb, alphabet_mapper * am) { + for(uint i=0;imap((uint)symbols[i]); + this->am = am; + am->use(); + this->c=c; + c->use(); + root = new wt_node_internal(symbols, n, 0, c, bmb); + symbols = 0; // Already deleted! +// for(uint i=0;iunmap((uint)symbols[i]); +} + static_sequence_wvtree::static_sequence_wvtree() {} static_sequence_wvtree::~static_sequence_wvtree() { @@ -50,7 +63,9 @@ uint static_sequence_wvtree::count(uint s) { } uint static_sequence_wvtree::select(uint symbol, uint pos) { - return root->select(am->map(symbol), pos, 0, c)-1; + uint ret = root->select(am->map(symbol), pos, 0, c); + if(ret==((uint)-1)) return (uint)-1; + return ret-1; } uint static_sequence_wvtree::access(uint pos) {