RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
BitVect.h
Go to the documentation of this file.
1//
2// Copyright (c) 2003-2008 greg Landrum and Rational Discovery LLC
3//
4// @@ All Rights Reserved @@
5// This file is part of the RDKit.
6// The contents are covered by the terms of the BSD license
7// which is included in the file license.txt, found at the root
8// of the RDKit source tree.
9//
10#include <RDGeneral/export.h>
11#ifndef __RD_BITVECT_H__
12#define __RD_BITVECT_H__
13
14#include <vector>
15#include <string>
16
17typedef std::vector<int> IntVect;
18typedef IntVect::iterator IntVectIter;
19typedef std::vector<double> DoubleVect;
20typedef DoubleVect::iterator DoubleVectIter;
21const int ci_BITVECT_VERSION = 0x0020; //!< version number to use in pickles
22
23//! Abstract base class for storing BitVectors
25 public:
26 virtual ~BitVect() = 0;
27 //! sets a particular bit and returns its original value
28 virtual bool setBit(const unsigned int which) = 0;
29 //! unsets a particular bit and returns its original value
30 virtual bool unsetBit(const unsigned int which) = 0;
31 //! returns the value of a particular bit
32 virtual bool getBit(const unsigned int which) const = 0;
33 //! returns the number of bits (the length of the BitVect)
34 virtual unsigned int getNumBits() const = 0;
35 //! returns the number of on bits
36 virtual unsigned int getNumOnBits() const = 0;
37 //! returns the number of off bits
38 virtual unsigned int getNumOffBits() const = 0;
39 //! replaces the contents of \c v with indices of our on bits
40 virtual void getOnBits(IntVect& v) const = 0;
41 //! clears (sets to off) all of our bits
42 virtual void clearBits() = 0;
43
44 //! initializes this BitVect from a pickle
45 /*!
46 \param data the raw pickle data
47 \param dataLen the length of \c data
48 \param isBase64 (optional) if this is set, \c data is assumed to
49 be base64 encoded.
50 \param allowOldFormat (optional) allows a very old form of the BitVect
51 representation to be recognized. This argument disables a large
52 amount of error checking and it is strongly suggested that it not
53 be used in client code.
54 */
55 void initFromText(const char* data, const unsigned int dataLen,
56 bool isBase64 = false, bool allowOldFormat = false);
57
58 //! returns a serialized (pickled) version of this BitVect
59 virtual std::string toString() const = 0;
60
61 virtual bool operator[](const unsigned int which) const = 0;
62 unsigned int size() const { return getNumBits(); }
63
64 private:
65 virtual void _initForSize(const unsigned int size) = 0;
66};
67
68#endif
DoubleVect::iterator DoubleVectIter
Definition BitVect.h:20
std::vector< int > IntVect
Definition BitVect.h:17
IntVect::iterator IntVectIter
Definition BitVect.h:18
const int ci_BITVECT_VERSION
version number to use in pickles
Definition BitVect.h:21
std::vector< double > DoubleVect
Definition BitVect.h:19
Abstract base class for storing BitVectors.
Definition BitVect.h:24
unsigned int size() const
Definition BitVect.h:62
void initFromText(const char *data, const unsigned int dataLen, bool isBase64=false, bool allowOldFormat=false)
initializes this BitVect from a pickle
virtual bool unsetBit(const unsigned int which)=0
unsets a particular bit and returns its original value
virtual void clearBits()=0
clears (sets to off) all of our bits
virtual std::string toString() const =0
returns a serialized (pickled) version of this BitVect
virtual unsigned int getNumBits() const =0
returns the number of bits (the length of the BitVect)
virtual ~BitVect()=0
virtual void getOnBits(IntVect &v) const =0
replaces the contents of v with indices of our on bits
virtual bool operator[](const unsigned int which) const =0
virtual bool getBit(const unsigned int which) const =0
returns the value of a particular bit
virtual unsigned int getNumOffBits() const =0
returns the number of off bits
virtual unsigned int getNumOnBits() const =0
returns the number of on bits
virtual bool setBit(const unsigned int which)=0
sets a particular bit and returns its original value
#define RDKIT_DATASTRUCTS_EXPORT
Definition export.h:81