10 #ifndef __RD_DISCRETE_VALUE_VECT_20050124__
11 #define __RD_DISCRETE_VALUE_VECT_20050124__
13 #include <boost/smart_ptr.hpp>
16 #include <boost/cstdint.hpp>
25 typedef boost::shared_array<boost::uint32_t>
DATA_SPTR;
38 : d_type(valType), d_length(length) {
39 d_bitsPerVal = (1 <<
static_cast<unsigned int>(valType));
40 d_valsPerInt = BITS_PER_INT / d_bitsPerVal;
41 d_numInts = (length + d_valsPerInt - 1) / d_valsPerInt;
42 d_mask = ((1 << d_bitsPerVal) - 1);
43 boost::uint32_t *data =
new boost::uint32_t[d_numInts];
44 memset(static_cast<void *>(data), 0, d_numInts *
sizeof(boost::uint32_t));
53 initFromText(pkl.c_str(), pkl.size());
57 initFromText(pkl, len);
63 unsigned int getVal(
unsigned int i)
const;
73 void setVal(
unsigned int i,
unsigned int val);
84 const boost::uint32_t *
getData()
const;
124 unsigned int d_bitsPerVal;
125 unsigned int d_valsPerInt;
126 unsigned int d_numInts;
127 unsigned int d_length;
131 void initFromText(
const char *pkl,
const unsigned int len);
135 const DiscreteValueVect &v2);
137 DiscreteValueVect
operator+(
const DiscreteValueVect &p1,
138 const DiscreteValueVect &p2);
139 DiscreteValueVect
operator-(
const DiscreteValueVect &p1,
140 const DiscreteValueVect &p2);
unsigned int getVal(unsigned int i) const
return the value at an index
unsigned int getNumInts() const
returns the size of our storage
DiscreteValueType
used to define the possible range of the values
boost::shared_array< boost::uint32_t > DATA_SPTR
const boost::uint32_t * getData() const
return a pointer to our raw data storage
DiscreteValueVect operator|(const DiscreteValueVect &other) const
support dvv3 = dvv1|dvv2
DiscreteValueVect(DiscreteValueType valType, unsigned int length)
initialize with a particular type and size
unsigned int size() const
returns the length
std::string toString() const
returns a binary string representation (pickle)
void setVal(unsigned int i, unsigned int val)
set the value at an index
DiscreteValueVect(const std::string &pkl)
constructor from a pickle
a class for efficiently storing vectors of discrete values
DiscreteValueVect & operator-=(const DiscreteValueVect &other)
DiscreteValueVect & operator+=(const DiscreteValueVect &other)
unsigned int getLength() const
returns the length
int operator[](unsigned int idx) const
support indexing using []
DiscreteValueVect(const char *pkl, const unsigned int len)
constructor from a pickle
Includes a bunch of functionality for handling Atom and Bond queries.
DiscreteValueVect operator-(const DiscreteValueVect &p1, const DiscreteValueVect &p2)
DiscreteValueVect operator+(const DiscreteValueVect &p1, const DiscreteValueVect &p2)
DiscreteValueVect operator&(const DiscreteValueVect &other) const
support dvv3 = dvv1&dvv2
unsigned int getNumBitsPerVal() const
return the number of bits used to store each value
const unsigned int BITS_PER_INT
unsigned int getTotalVal() const
returns the sum of all the elements in the vect
unsigned int computeL1Norm(const DiscreteValueVect &v1, const DiscreteValueVect &v2)
DiscreteValueType getValueType() const
return the type of value being stored