RDCode: BitVect.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories

# BitVect.h

Go to the documentation of this file.

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