From 06201fcce6255906ad6b4d305b8e643c634780a3 Mon Sep 17 00:00:00 2001 From: fclaude Date: Tue, 24 Mar 2009 02:18:48 +0000 Subject: [PATCH] Fixes git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/XMLTree@276 3cdefd35-fc62-479d-8e8d-bae585ffb9ca --- libcds/src/static_bitsequence/sdarray.cpp | 108 +++++++++--------- libcds/src/static_bitsequence/sdarray.h | 2 +- .../static_bitsequence_sdarray.cpp | 2 +- 3 files changed, 56 insertions(+), 56 deletions(-) diff --git a/libcds/src/static_bitsequence/sdarray.cpp b/libcds/src/static_bitsequence/sdarray.cpp index 3b772cc..2b08dc3 100644 --- a/libcds/src/static_bitsequence/sdarray.cpp +++ b/libcds/src/static_bitsequence/sdarray.cpp @@ -26,7 +26,7 @@ typedef unsigned long long qword; #define logL (logLL-1-5) #define L (1<0) { @@ -37,7 +37,7 @@ int blog(int x) { } -int setbit(uint *B, int i,int x) { +int __setbit(uint *B, int i,int x) { int j,l; //printf("%u\n",D); j = i / D; @@ -45,14 +45,14 @@ int setbit(uint *B, int i,int x) { if (x==0) B[j] &= (~(1<<(D-1-l))); else if (x==1) B[j] |= (1<<(D-1-l)); else { - printf("error setbit x=%d\n",x); + printf("error __setbit x=%d\n",x); exit(1); } return x; } -int setbit2(uchar *B, int i,int x) { +int __setbit2(uchar *B, int i,int x) { int j,l; j = i / 8; @@ -60,24 +60,24 @@ int setbit2(uchar *B, int i,int x) { if (x==0) B[j] &= (~(1<<(8-1-l))); else if (x==1) B[j] |= (1<<(8-1-l)); else { - printf("error setbit2 x=%d\n",x); + printf("error __setbit2 x=%d\n",x); exit(1); } return x; } -int setbits(uint *B, int i, int d, int x) { +int __setbits(uint *B, int i, int d, int x) { int j; for (j=0; j>(d-j-1))&1); + __setbit(B,i+j,(x>>(d-j-1))&1); } return x; } -int getbit(uint *B, int i) { +int __getbit(uint *B, int i) { int j,l; //j = i / D; @@ -88,7 +88,7 @@ int getbit(uint *B, int i) { } -int getbit2(uchar *B, int i) { +int __getbit2(uchar *B, int i) { int j,l; //j = i / D; @@ -100,7 +100,7 @@ int getbit2(uchar *B, int i) { #if 1 -uint getbits(uint *B, int i, int d) { +uint __getbits(uint *B, int i, int d) { qword x,z; B += (i >> logD); @@ -127,19 +127,19 @@ uint getbits(uint *B, int i, int d) { #endif #if 0 -uint getbits(uint *B, int i, int d) { +uint __getbits(uint *B, int i, int d) { uint j,x; x = 0; for (j=0; j>16) + (r & 0x0000ffff); r = ((r>>16) + r) & 63; #else - r = popCount[x & 0xff]; + r = __popCount[x & 0xff]; x >>= 8; - r += popCount[x & 0xff]; + r += __popCount[x & 0xff]; x >>= 8; - r += popCount[x & 0xff]; + r += __popCount[x & 0xff]; x >>= 8; - r += popCount[x & 0xff]; + r += __popCount[x & 0xff]; #endif return r; } -unsigned int popcount8(uint x) { +unsigned int __popCount8(uint x) { uint r; #if 1 r = x; @@ -214,7 +214,7 @@ unsigned int popcount8(uint x) { r = ((r & 0xcc)>>2) + (r & 0x33); r = ((r>>4) + r) & 0x0f; #else - r = popCount[x & 0xff]; + r = __popCount[x & 0xff]; #endif return r; } @@ -276,7 +276,7 @@ int selectd2_construct(selectd2 *select, int n, uchar *buf) { int r; uint *s; - make_selecttbl(); + make___selecttbl(); if (L/LLL == 0) { printf("ERROR: L=%d LLL=%d\n",L,LLL); @@ -284,7 +284,7 @@ int selectd2_construct(selectd2 *select, int n, uchar *buf) { } m = 0; - for (i=0; in = n; select->m = m; //printf("n=%d m=%d\n",n,m); @@ -294,7 +294,7 @@ int selectd2_construct(selectd2 *select, int n, uchar *buf) { s = new uint[m]; m = 0; for (i=0; i> (8-1-rr)]; + r -= __popCount[*q >> (8-1-rr)]; //p = p - rr; while (1) { - rr = popCount[*q]; + rr = __popCount[*q]; if (r + rr >= i) break; r += rr; //p += 8; q++; } p = (q - select->buf) << 3; - p += selecttbl[((i-r-1)<<8)+(*q)]; + p += __selecttbl[((i-r-1)<<8)+(*q)]; } else { rr = p & (8-1); - r -= popCount[(*q ^ 0xff) >> (8-1-rr)]; + r -= __popCount[(*q ^ 0xff) >> (8-1-rr)]; //p = p - rr; while (1) { - rr = popCount[*q ^ 0xff]; + rr = __popCount[*q ^ 0xff]; if (r + rr >= i) break; r += rr; //p += 8; q++; } p = (q - select->buf) << 3; - p += selecttbl[((i-r-1)<<8)+(*q ^ 0xff)]; + p += __selecttbl[((i-r-1)<<8)+(*q ^ 0xff)]; } } return p; @@ -463,29 +463,29 @@ int selectd2_select2(selectd2 *select, int i,int f, int *st, int *en) { if (f == 1) { rr = p & (8-1); - r -= popCount[*q >> (8-1-rr)]; + r -= __popCount[*q >> (8-1-rr)]; //p = p - rr; while (1) { - rr = popCount[*q]; + rr = __popCount[*q]; if (r + rr >= i) break; r += rr; //p += 8; q++; } p = (q - select->buf) << 3; - p += selecttbl[((i-r-1)<<8)+(*q)]; + p += __selecttbl[((i-r-1)<<8)+(*q)]; if ((i>>logL) == ((i+1)>>logL)) { i++; while (1) { - rr = popCount[*q]; + rr = __popCount[*q]; if (r + rr >= i) break; r += rr; q++; } p2 = (q - select->buf) << 3; - p2 += selecttbl[((i-r-1)<<8)+(*q)]; + p2 += __selecttbl[((i-r-1)<<8)+(*q)]; } else { p2 = selectd2_select(select,i+2,f); @@ -494,29 +494,29 @@ int selectd2_select2(selectd2 *select, int i,int f, int *st, int *en) { } else { rr = p & (8-1); - r -= popCount[(*q ^ 0xff) >> (8-1-rr)]; + r -= __popCount[(*q ^ 0xff) >> (8-1-rr)]; //p = p - rr; while (1) { - rr = popCount[*q ^ 0xff]; + rr = __popCount[*q ^ 0xff]; if (r + rr >= i) break; r += rr; //p += 8; q++; } p = (q - select->buf) << 3; - p += selecttbl[((i-r-1)<<8)+(*q ^ 0xff)]; + p += __selecttbl[((i-r-1)<<8)+(*q ^ 0xff)]; if ((i>>logL) == ((i+1)>>logL)) { i++; while (1) { - rr = popCount[*q ^ 0xff]; + rr = __popCount[*q ^ 0xff]; if (r + rr >= i) break; r += rr; q++; } p2 = (q - select->buf) << 3; - p2 += selecttbl[((i-r-1)<<8)+(*q ^ 0xff)]; + p2 += __selecttbl[((i-r-1)<<8)+(*q ^ 0xff)]; } else { p2 = selectd2_select(select,i+2,f); @@ -589,7 +589,7 @@ int selects3_construct(selects3 *select, int n, uint *buf) { selectd2 *sd0,*sd1; m = 0; - for (i=0; in = n; select->m = m; @@ -615,13 +615,13 @@ int selects3_construct(selects3 *select, int n, uint *buf) { select->low = low; select->size = sizeof(uchar)*((2*m+8-1)/8+1) + sizeof(uint)*((d*m+PBS-1)/PBS+1); - for (i=0; i>d)+m,1); - setbits(low,m*d,d,i & ((1<>d)+m,1); + __setbits(low,m*d,d,i & ((1<sd1 = sd1; - for (i=0; isd0 = sd0; - for (i=0; isd1,i,1) - (i-1); x <<= d; - x += getbits(select->low,(i-1)*d,d); + x += __getbits(select->low,(i-1)*d,d); return x; } @@ -687,7 +687,7 @@ int selects3_rank(selects3 *select, int i) { z = select->hi[y]; while (1) { if (((z << r) & 0x80) == 0) break; - w = getbits(q,x*d,d); + w = __getbits(q,x*d,d); if (w >= j) { if (w == j) x++; break; diff --git a/libcds/src/static_bitsequence/sdarray.h b/libcds/src/static_bitsequence/sdarray.h index a6d28b6..4fa12e8 100644 --- a/libcds/src/static_bitsequence/sdarray.h +++ b/libcds/src/static_bitsequence/sdarray.h @@ -33,7 +33,7 @@ int selects3_construct(selects3 *select, int n, uint *buf); int selects3_select(selects3 *select, int i); int selects3_rank(selects3 *select, int i); -int setbit(uint *B, int i,int x); +int __setbit(uint *B, int i,int x); int selectd2_save(selectd2 * s, FILE * fp); int selects3_save(selects3 * s, FILE * fp); diff --git a/libcds/src/static_bitsequence/static_bitsequence_sdarray.cpp b/libcds/src/static_bitsequence/static_bitsequence_sdarray.cpp index e50e074..41bd316 100644 --- a/libcds/src/static_bitsequence/static_bitsequence_sdarray.cpp +++ b/libcds/src/static_bitsequence/static_bitsequence_sdarray.cpp @@ -8,7 +8,7 @@ static_bitsequence_sdarray::static_bitsequence_sdarray(uint * buff, uint len) { tmp_seq[i] = 0; for(uint i=0;i