00001 # ifndef BitOverlay_h
00002 # define BitOverlay_h BitInfo_h
00003
00004
00005
00006 # include "Root.h"
00007 # include <string>
00008
00009 namespace Conjecture {
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class BitOverlay : public Root {
00040 public:
00049 typedef unsigned int Layout;
00050
00068 typedef int BitPos;
00069 static const BitPos npos = 255;
00070
00075 typedef unsigned BitCount;
00076
00077 inline BitOverlay(Layout data) { this->bitsIs(data); }
00078
00079
00080 inline Layout bits() const { return this->_bits; }
00081
00082
00083
00092 static BitPos FindFirstHigh(Layout val);
00093 inline BitPos findFirstHigh() const { return FindFirstHigh(this->_bits); }
00094 static BitPos FindFirstHighSlow(Layout val);
00095
00100 static BitPos FindFirstLow(Layout val);
00101 inline BitPos findFirstLow() const { return FindFirstLow(this->_bits); }
00102
00107 static inline int _bx(Layout x) { return (x - ((x>>1)&0x77777777) - ((x>>2)&0x33333333) - ((x>>3)&0x11111111)); }
00108 static inline BitCount PopCount(Layout val) { return (((_bx(val)+(_bx(val)>>4)) & 0x0F0F0F0F) % 255); }
00109 inline BitCount popc() const { return PopCount(this->_bits); }
00110 static BitCount PopCountSlow(Layout val);
00111
00120 static std::string Str(Layout val);
00121 inline std::string str() const { return Str(this->_bits); }
00122
00131 static BitCount Regions(Layout val, int* largest = NULL, int* all = NULL);
00132 inline BitCount regions(int* largest = NULL, int* all = NULL) const { return Regions(this->_bits, largest, all); }
00133
00138 static void Test(int argc = 0, const char* argv[] = NULL);
00139
00140 protected:
00141
00142 inline void bitsIs(const Layout & bits) { this->_bits = bits; }
00143
00144
00145
00146 private:
00147
00148 inline Layout & bitsRef() { return this->_bits; }
00149
00150
00151
00152
00153 Layout _bits;
00154 };
00155 }
00156
00157 # endif // BitOverlay_h
00158