X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=darray.c;h=780b9673c0463f5a53a83dfdc3b835bfe6883400;hb=1c40b498ddd6d66b09aff3a22b9f7ddd845250dc;hp=3359ed305466da861d6f3815097aeb30bcc2b267;hpb=912ff50e1d38de484b503d8ef877a49a65765ab9;p=SXSI%2FXMLTree.git diff --git a/darray.c b/darray.c index 3359ed3..780b967 100644 --- a/darray.c +++ b/darray.c @@ -46,6 +46,27 @@ int setbit(pb *B, int i,int x) return x; } +int setbit_zero(pb *B, int i) +{ + int j,l; + j = i >> 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;