X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=libcds%2Fsrc%2Fstatic_bitsequence%2Fsdarray.cpp;h=2294a0cc983d63ad2c92f6601b151f6b70236c7f;hb=b5efc7c4db3195fdbee1e63ae477d95d41a94752;hp=44b61ac86e676b0e0cb5e52ed8458390dac627ca;hpb=3297037dfd6a0e9654b9d6431934ff512f6bd7ea;p=SXSI%2FXMLTree.git diff --git a/libcds/src/static_bitsequence/sdarray.cpp b/libcds/src/static_bitsequence/sdarray.cpp index 44b61ac..2294a0c 100644 --- a/libcds/src/static_bitsequence/sdarray.cpp +++ b/libcds/src/static_bitsequence/sdarray.cpp @@ -159,8 +159,11 @@ static const unsigned int _popCount[] = { }; static unsigned int __selecttbl[8*256]; +static int built = 0; void make___selecttbl(void) { + if(built) return; + built = 1; int i,x,r; uint buf[1]; @@ -649,9 +652,9 @@ int selects3_construct(selects3 *select, int n, uint *buf) { return 0; } -selects3 * lasts3=NULL; -int lasti=0; -int lasts=0; +//selects3 * lasts3=NULL; +//int lasti=0; +//int lasts=0; int selects3_select(selects3 *select, int i) { int d,x; @@ -666,22 +669,24 @@ int selects3_select(selects3 *select, int i) { if (i == 0) return -1; d = select->d; - if(lasts3==select && lasti==i-1) { - while(!__getbit2(select->sd1->buf,++lasti)); + /*if(select->lasti==(uint)i-1) { + while(!__getbit2(select->sd1->buf,++select->lasts)); } else { - lasts = selectd2_select(select->sd1,i,1); + select->lasts = selectd2_select(select->sd1,i,1); } - lasti = i; - lasts3 = select; - x = (lasts-(i-1)) << d; + select->lasti = i; + //lasts3 = select; */ + x = selectd2_select(select->sd1,i,1) - (i-1); + //x = (select->lasts-(i-1)) << d; + x <<= 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); + //return selects3_select(select,selects3_rank(select,i)+1); int d,x,w,y; int r,j; int z,ii; @@ -753,6 +758,7 @@ int selects3_rank(selects3 *select, int i) { q = select->low; ii = i>>d; + y = selectd2_select(select->sd0,ii,0)+1; // selectd2_select2(select->sd0,ii,0,&y1,&y2); //y1++; y2++;