BitVect.h

Go to the documentation of this file.
00001 //
00002 // Copyright (c) 2003-2008 greg Landrum and Rational Discovery LLC
00003 //
00004 //  @@ All Rights Reserved @@
00005 //
00006 #ifndef __RD_BITVECT_H__
00007 #define __RD_BITVECT_H__
00008 
00009 #include <vector>
00010 #include <string>
00011 
00012 using std::vector;
00013 typedef vector<int> IntVect;
00014 typedef IntVect::iterator IntVectIter;
00015 typedef vector<double> DoubleVect;
00016 typedef DoubleVect::iterator DoubleVectIter;
00017 const int ci_BITVECT_VERSION=0x0020; //!< version number to use in pickles
00018 
00019 //! Abstract base class for storing BitVectors
00020 class BitVect{
00021 public:
00022   virtual ~BitVect() = 0;
00023   //! sets a particular bit and returns its original value
00024   virtual bool SetBit(const unsigned int which) = 0;
00025   //! unsets a particular bit and returns its original value
00026   virtual bool UnSetBit(const unsigned int which) = 0;
00027   //! returns the value of a particular bit
00028   virtual bool GetBit(const unsigned int which) const = 0;
00029   //! returns the number of bits (the length of the BitVect)
00030   virtual const unsigned int GetNumBits() const = 0;
00031   //! returns the number of on bits
00032   virtual const unsigned int GetNumOnBits() const = 0;
00033   //! returns the number of off bits
00034   virtual const unsigned int GetNumOffBits() const =0;
00035   //! replaces the contents of \c v with indices of our on bits
00036   virtual void GetOnBits (IntVect& v) const = 0;
00037   //! clears (sets to off) all of our bits
00038   virtual void ClearBits() = 0;
00039 
00040   //! initializes this BitVect from a pickle
00041   /*!
00042     \param data     the raw pickle data
00043     \param dataLen  the length of \c data 
00044     \param isBase64 (optional) if this is set, \c data is assumed to
00045          be base64 encoded.
00046     \param allowOldFormat (optional) allows a very old form of the BitVect
00047          representation to be recognized. This argument disables a large
00048          amount of error checking and it is strongly suggested that it not
00049          be used in client code.
00050    */
00051   void InitFromText(const char *data,const unsigned int dataLen,
00052                     bool isBase64=false,bool allowOldFormat=false);
00053                     
00054   //! returns a serialized (pickled) version of this BitVect
00055   virtual std::string ToString() const = 0;
00056 
00057   virtual bool operator[] (const unsigned int which) const = 0;
00058 
00059 private:
00060   virtual void _InitForSize(const unsigned int size) = 0;
00061 };
00062 
00063 
00064 #endif

Generated on Fri Apr 3 06:03:01 2009 for RDCode by  doxygen 1.5.6