X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=darray.c;h=780b9673c0463f5a53a83dfdc3b835bfe6883400;hb=1c40b498ddd6d66b09aff3a22b9f7ddd845250dc;hp=7d302c49a6e8deaee94ac4017341162d32e40209;hpb=0bf9688e2615a9fc07860c5762240e4ce26ee5d3;p=SXSI%2FXMLTree.git diff --git a/darray.c b/darray.c index 7d302c4..780b967 100644 --- a/darray.c +++ b/darray.c @@ -7,7 +7,7 @@ //typedef unsigned int dword; //typedef dword pb; -#define logD 5 +//#define logD 5 #define PBS (sizeof(pb)*8) #define D (1<> logD; + l = i & (D-1); + B[j] &= (~(1<<(D-1-l))); + return 0; +} + +int setbit_one(pb *B, int i) +{ + int j,l; + j = i >> logD; + l = i & (D-1); + B[j] |= (1<<(D-1-l)); + return 1; + +} + + + int setbits(pb *B, int i, int d, int x) { int j; @@ -113,7 +134,7 @@ static const unsigned int popCount[] = { static int selecttbl[8*256]; -unsigned int popcount(pb x) +unsigned int popcount_old(pb x) { pb r; #if 0 @@ -142,6 +163,18 @@ unsigned int popcount(pb x) return r; } +inline unsigned int +popcount(pb x) +{ + uint m1 = 0x55555555; + uint m2 = 0xc30c30c3; + x -= (x >> 1) & m1; + x = (x & m2) + ((x >> 2) & m2) + ((x >> 4) & m2); + x += x >> 6; + return (x + (x >> 12) + (x >> 24)) & 0x3f; +} + + unsigned int popcount8(pb x) { dword r;