Add beginnings of bitslice test
Add initial cross-platform support header
De-tabulate MurmurHash3, and make it compile under GCC w/ Platform.h
git-svn-id: http://smhasher.googlecode.com/svn/trunk@86 77a7d1d3-4c08-bdc2-d393-d5859734b01a
diff --git a/Bitvec.cpp b/Bitvec.cpp
index 6939980..58f0aca 100644
--- a/Bitvec.cpp
+++ b/Bitvec.cpp
@@ -146,6 +146,17 @@
if(byte < len) b[byte] ^= (1 << bit);
}
+// from the "Bit Twiddling Hacks" webpage
+
+int countbits ( uint32_t v )
+{
+ v = v - ((v >> 1) & 0x55555555); // reuse input as temporary
+ v = (v & 0x33333333) + ((v >> 2) & 0x33333333); // temp
+ int c = ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; // count
+
+ return c;
+}
+
//-----------------------------------------------------------------------------
void lshift1 ( void * blob, int len, int c )