BitOverlay.h

00001 # ifndef Conjecture_BitOverlay_h
00002 # define Conjecture_BitOverlay_h Conjecture_BitInfo_h
00003 
00004 // Insert SVN header substitution variable here
00005 // Class Champion: Unassigned
00006 
00007 // # Created 2006/06/09 by wade
00008 
00009 # include "Root.h"  // parent
00010 # include <string>
00011 
00012 namespace Conjecture {
00013     
00042     class BitOverlay : public Root {
00043       public:
00052         typedef unsigned int Layout;
00053 
00071         typedef int BitPos;
00072         static const BitPos npos = 255;
00073 
00078         typedef unsigned BitCount;
00079 
00080         inline BitOverlay(Layout data) { this->bitsIs(data); }
00081         
00082         // Accessors
00083         inline Layout bits() const { return this->_bits; }
00084         
00085         // Interface
00086 
00095         static BitPos FindFirstHigh(Layout val);
00096         inline BitPos findFirstHigh() const { return FindFirstHigh(this->_bits); }
00097         static BitPos FindFirstHighSlow(Layout val);
00098 
00103         static BitPos FindFirstLow(Layout val);
00104         inline BitPos findFirstLow() const { return FindFirstLow(this->_bits); }
00105 
00110         static inline int _bx(Layout x)             { return (x - ((x>>1)&0x77777777) - ((x>>2)&0x33333333) - ((x>>3)&0x11111111)); }
00111         static inline BitCount PopCount(Layout val) { return (((_bx(val)+(_bx(val)>>4)) & 0x0F0F0F0F) % 255); }
00112         inline BitCount popc() const                { return PopCount(this->_bits); }
00113         static BitCount PopCountSlow(Layout val);
00114 
00123         static std::string Str(Layout val);
00124         inline std::string str() const { return Str(this->_bits); }
00125 
00134         static BitCount Regions(Layout val, int* largest = NULL, int* all = NULL);
00135         inline BitCount regions(int* largest = NULL, int* all = NULL) const { return Regions(this->_bits, largest, all); }
00136 
00141         static void Test(int argc = 0, const char* argv[] = NULL);
00142         
00143       protected:
00144         // Accessors
00145         inline void bitsIs(const Layout & bits) { this->_bits = bits; }
00146         
00147         // Methods 
00148         
00149       private: 
00150         // Accessors
00151         inline Layout &  bitsRef() { return this->_bits; }
00152         
00153         // Methods 
00154         
00155         // State
00156         Layout    _bits;
00157     };
00158 }
00159 
00160 # endif // Conjecture_BitOverlay_h
00161 

Generated on Thu Jun 15 19:56:09 2006 for Conjecture by  doxygen 1.4.6