X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=libcds%2Fsrc%2Fstatic_bitsequence%2Fsdarray.cpp;h=cd46b665ebbe6aadbddd9f1c7251f12dfd7a78e8;hb=a99449f19289d6b44eaac26d62eb21b21741b593;hp=58b72e0500c9b0fd80969d51a45bc855bac8e2e8;hpb=137f5dd42abc5afe132ef3f45dcb7f2bf2b595db;p=SXSI%2FXMLTree.git diff --git a/libcds/src/static_bitsequence/sdarray.cpp b/libcds/src/static_bitsequence/sdarray.cpp index 58b72e0..cd46b66 100644 --- a/libcds/src/static_bitsequence/sdarray.cpp +++ b/libcds/src/static_bitsequence/sdarray.cpp @@ -649,6 +649,9 @@ int selects3_construct(selects3 *select, int n, uint *buf) { return 0; } +//selects3 * lasts3=NULL; +//int lasti=0; +//int lasts=0; int selects3_select(selects3 *select, int i) { int d,x; @@ -663,16 +666,22 @@ int selects3_select(selects3 *select, int i) { if (i == 0) return -1; d = select->d; - - x = selectd2_select(select->sd1,i,1) - (i-1); - x <<= d; + if(select->lasti==(uint)i-1) { + while(!__getbit2(select->sd1->buf,++select->lasti)); + } + else { + select->lasts = selectd2_select(select->sd1,i,1); + } + select->lasti = i; + //lasts3 = select; + x = (select->lasts-(i-1)) << d; x += __getbits(select->low,(i-1)*d,d); return x; - } int selects3_selectnext(selects3 *select, int i) { + return selects3_select(select,selects3_rank(select,i)+1); int d,x,w,y; int r,j; int z,ii;