X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=libcds%2Fsrc%2Fstatic_sequence%2Fwt_node_internal.cpp;h=9dc87a2a5b3095c909be06342a5a5c1657ca92b7;hb=279e273b1928bbef4c960d6ce9b77f9c3fbecef9;hp=d2d0fa8e771a3ffcf90e7fac745a1e06ef04e494;hpb=82b89c86269e04916a4aef964977ee738d8f2927;p=SXSI%2FXMLTree.git diff --git a/libcds/src/static_sequence/wt_node_internal.cpp b/libcds/src/static_sequence/wt_node_internal.cpp index d2d0fa8..9dc87a2 100644 --- a/libcds/src/static_sequence/wt_node_internal.cpp +++ b/libcds/src/static_sequence/wt_node_internal.cpp @@ -142,19 +142,22 @@ uint wt_node_internal::rank(uint symbol, uint pos, uint l, wt_coder * c) { uint wt_node_internal::select(uint symbol, uint pos, uint l, wt_coder * c) { bool is_set = c->is_set(symbol, l); + uint ret = 0; if(!is_set) { if(left_child==NULL) return (uint)(-1); uint new_pos = left_child->select(symbol, pos, l+1,c); if(new_pos+1==0) return (uint)(-1); - return bitmap->select0(new_pos)+1; + ret = bitmap->select0(new_pos)+1; } else { if(right_child==NULL) return (uint)(-1); uint new_pos = right_child->select(symbol, pos, l+1,c); if(new_pos+1==0) return (uint)(-1); - return bitmap->select1(new_pos)+1; + ret = bitmap->select1(new_pos)+1; } + if(ret==0) return (uint)-1; + return ret; } uint wt_node_internal::access(uint pos) {