00001 // 00002 // Copyright (c) 2003-2006 greg Landrum and Rational Discovery LLC 00003 // 00004 // @@ All Rights Reserved @@ 00005 // 00006 #ifndef __RD_EXPLICITBITVECTS_H__ 00007 #define __RD_EXPLICITBITVECTS_H__ 00008 00009 #include <boost/dynamic_bitset.hpp> 00010 #include "BitVect.h" 00011 00012 //! a class for bit vectors that are densely occupied 00013 /*! 00014 ExplicitBitVect objects store all of their bits using 00015 a boost::dynamic_bitset 00016 00017 These are very fast, but can require large amounts of memory for large, 00018 sparsely occupied vectors. 00019 00020 */ 00021 class ExplicitBitVect : public BitVect { 00022 public: 00023 ExplicitBitVect() : dp_bits(0), d_size(0), d_numOnBits(0) {}; 00024 //! initialize with a particular size; 00025 explicit ExplicitBitVect(unsigned int size) : dp_bits(0), d_size(0), d_numOnBits(0) {_InitForSize(size);}; 00026 ExplicitBitVect(const ExplicitBitVect& other); 00027 //! construct from a string pickle 00028 ExplicitBitVect(const std::string); 00029 //! construct from a text pickle 00030 ExplicitBitVect(const char *,const unsigned int); 00031 00032 ~ExplicitBitVect(); 00033 00034 ExplicitBitVect& operator=(const ExplicitBitVect& other); 00035 bool operator[] (const unsigned int which) const; 00036 bool SetBit(const unsigned int which); 00037 bool UnSetBit(const unsigned int which); 00038 bool GetBit(const unsigned int which) const; 00039 00040 ExplicitBitVect operator^ (const ExplicitBitVect &other) const; 00041 ExplicitBitVect operator& (const ExplicitBitVect &other) const; 00042 ExplicitBitVect operator| (const ExplicitBitVect &other) const; 00043 ExplicitBitVect operator~ () const; 00044 const unsigned int GetNumBits() const; 00045 const unsigned int GetNumOnBits() const; 00046 const unsigned int GetNumOffBits() const; 00047 00048 void GetOnBits (IntVect& v) const; 00049 00050 // FIX: complete these 00051 void ClearBits() { dp_bits->reset(); }; 00052 std::string ToString() const; 00053 00054 boost::dynamic_bitset<> *dp_bits; //!< our raw storage 00055 private: 00056 unsigned int d_size; 00057 unsigned int d_numOnBits; 00058 void _InitForSize(const unsigned int size); 00059 }; 00060 00061 00062 #endif
1.5.3