X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=libcds%2Fsrc%2Fstatic_sequence%2Fwt_node_leaf.cpp;h=6c036fd212b045c78a52dcf6616b8df69bc4a7c3;hb=95f2dabec7cabe4002865e5f9d12651e6e32229a;hp=e3b7c195c60fd2477dbe94ab658393c32d258e5b;hpb=450ba3c9c74665094fb8f6821d6cc92d2bf23011;p=SXSI%2FXMLTree.git diff --git a/libcds/src/static_sequence/wt_node_leaf.cpp b/libcds/src/static_sequence/wt_node_leaf.cpp index e3b7c19..6c036fd 100644 --- a/libcds/src/static_sequence/wt_node_leaf.cpp +++ b/libcds/src/static_sequence/wt_node_leaf.cpp @@ -31,23 +31,57 @@ wt_node_leaf::wt_node_leaf() {} wt_node_leaf::~wt_node_leaf() {} uint wt_node_leaf::rank(uint symbol, uint pos, uint l, wt_coder * c) { - assert(symbol==this->symbol); + if(symbol!=this->symbol) return 0; pos++; - assert(pos<=count); return pos; } +uint wt_node_leaf::rankLessThan(uint &symbol, uint pos) { +// std::cout <<"this-symbol: " << (uchar)this->symbol << ", symbol = " << (uchar)symbol << ", pos = " << pos << std::endl; + if (pos == (uint)-1 || symbol < this->symbol) + return -1; + symbol = this->symbol; + pos++; + return pos; +} + uint wt_node_leaf::select(uint symbol, uint pos, uint l, wt_coder * c) { - assert(symbol==this->symbol); - assert(pos<=count && pos>0); + if(symbol!=this->symbol) return (uint)-1; + if(pos==0 || pos>count) return (uint)-1; return pos; } uint wt_node_leaf::access(uint pos) { - assert(possymbol << ", pos = " << pos << std::endl; + return symbol; } +void wt_node_leaf::access(vector &result, uint i, uint j, uint min, uint max, uint l, uint pivot) +{ +// std::cout << "At l = " << l << ", [" << i << ", " << j << "], [" << min << ", " << max << "], symbol = " << symbol << std::endl; + + if (i <= j && symbol >= min && symbol <= max) + result.push_back((int)symbol); +} + +void wt_node_leaf::access(vector &result, uint i, uint j) +{ +// std::cout << "At l = " << l << ", [" << i << ", " << j << "], [" << min << ", " << max << "], symbol = " << symbol << std::endl; + + if (i <= j) + result.push_back((int)symbol); +} + +uint wt_node_leaf::access(uint i, uint j, uint min, uint max, uint l, uint pivot) +{ +// std::cout << "At l = " << l << ", [" << i << ", " << j << "], [" << min << ", " << max << "], symbol = " << symbol << std::endl; + + if (i <= j && symbol >= min && symbol <= max) + return 1; + return 0; +} + uint wt_node_leaf::size() { return sizeof(wt_node_leaf); }