11 #ifndef __RD_DISCRETE_VALUE_VECT_20050124__ 12 #define __RD_DISCRETE_VALUE_VECT_20050124__ 14 #include <boost/smart_ptr.hpp> 17 #include <boost/cstdint.hpp> 26 typedef boost::shared_array<boost::uint32_t>
DATA_SPTR;
39 : d_type(valType), d_length(length) {
40 d_bitsPerVal = (1 <<
static_cast<unsigned int>(valType));
41 d_valsPerInt = BITS_PER_INT / d_bitsPerVal;
42 d_numInts = (length + d_valsPerInt - 1) / d_valsPerInt;
43 d_mask = ((1 << d_bitsPerVal) - 1);
44 boost::uint32_t *data =
new boost::uint32_t[d_numInts];
45 memset(static_cast<void *>(data), 0, d_numInts *
sizeof(boost::uint32_t));
54 initFromText(pkl.c_str(),
static_cast<unsigned int>(pkl.size()));
58 initFromText(pkl, len);
64 unsigned int getVal(
unsigned int i)
const;
67 int operator[](
unsigned int idx)
const {
return getVal(idx); };
74 void setVal(
unsigned int i,
unsigned int val);
77 unsigned int getTotalVal()
const;
80 unsigned int getLength()
const;
82 unsigned int size()
const {
return getLength(); };
85 const boost::uint32_t *getData()
const;
121 std::string toString()
const;
124 DiscreteValueType d_type;
125 unsigned int d_bitsPerVal;
126 unsigned int d_valsPerInt;
127 unsigned int d_numInts;
128 unsigned int d_length;
132 void initFromText(
const char *pkl,
const unsigned int len);
unsigned int size() const
returns the length
DiscreteValueType
used to define the possible range of the values
boost::shared_array< boost::uint32_t > DATA_SPTR
RDKIT_DATASTRUCTS_EXPORT DiscreteValueVect operator-(const DiscreteValueVect &p1, const DiscreteValueVect &p2)
DiscreteValueType getValueType() const
return the type of value being stored
DiscreteValueVect(DiscreteValueType valType, unsigned int length)
initialize with a particular type and size
#define RDKIT_DATASTRUCTS_EXPORT
unsigned int getNumBitsPerVal() const
return the number of bits used to store each value
RDKIT_DATASTRUCTS_EXPORT unsigned int computeL1Norm(const DiscreteValueVect &v1, const DiscreteValueVect &v2)
DiscreteValueVect(const std::string &pkl)
constructor from a pickle
a class for efficiently storing vectors of discrete values
unsigned int getNumInts() const
returns the size of our storage
DiscreteValueVect(const char *pkl, const unsigned int len)
constructor from a pickle
RDKIT_DATASTRUCTS_EXPORT DiscreteValueVect operator+(const DiscreteValueVect &p1, const DiscreteValueVect &p2)
int operator[](unsigned int idx) const
support indexing using []
const unsigned int BITS_PER_INT