mutable std::vector<std::string> subnames;
mutable std::vector<std::string> subdescs;
- virtual size_t size() const = 0;
+ virtual size_type size() const = 0;
virtual const VCounter &value() const = 0;
virtual const VResult &result() const = 0;
virtual Result total() const = 0;
update()
{
if (!subnames.empty()) {
- int s = size();
+ size_type s = size();
if (subnames.size() < s)
subnames.resize(s);
virtual bool zero() const { return s.zero(); }
virtual void reset() { s.reset(); }
- virtual size_t size() const { return s.size(); }
+ virtual size_type size() const { return s.size(); }
virtual VCounter &
value() const
Counter min;
Counter max;
Counter bucket_size;
- int size;
+ size_type size;
bool fancy;
};
/** Local storage for the entry values, used for printing. */
mutable VResult rvec;
- virtual size_t size() const = 0;
+ virtual size_type size() const = 0;
void
update()
{
- int s = size();
+ size_type s = size();
if (subnames.size() < s)
subnames.resize(s);
virtual bool check() const { return s.check(); }
virtual void reset() { s.reset(); }
- virtual size_t size() const { return s.size(); }
+ virtual size_type size() const { return s.size(); }
virtual bool zero() const { return s.zero(); }
virtual void
/** Local storage for the entry values, used for printing. */
mutable VCounter cvec;
- mutable int x;
- mutable int y;
+ mutable size_type x;
+ mutable size_type y;
void
update()
* @return A reference to this stat.
*/
Parent &
- subname(int index, const std::string &name)
+ subname(off_type index, const std::string &name)
{
std::vector<std::string> &subn = this->statData()->subnames;
if (subn.size() <= index)
* @return A reference to this stat.
*/
Parent &
- subdesc(int index, const std::string &desc)
+ subdesc(off_type index, const std::string &desc)
{
std::vector<std::string> &subd = this->statData()->subdescs;
if (subd.size() <= index)
{
Data<Child> *data = this->statData();
data->y_subnames.resize(this->y);
- for (int i = 0; i < this->y; ++i)
+ for (off_type i = 0; i < this->y; ++i)
data->y_subnames[i] = names[i];
return this->self();
}
Parent &
- ysubname(int index, const std::string subname)
+ ysubname(off_type index, const std::string subname)
{
Data<Child> *data = this->statData();
assert(index < this->y);
* Return the number of elements, always 1 for a scalar.
* @return 1.
*/
- size_t size() const { return 1; }
+ size_type size() const { return 1; }
bool check() const { return true; }
public:
virtual void visit(Visit &visitor) { visitor.visit(*this); }
virtual std::string str() const { return to_string(value()); }
- virtual size_t size() const { return 1; }
+ virtual size_type size() const { return 1; }
virtual bool zero() const { return value() == 0; }
virtual bool check() const { return true; }
virtual void reset() { }
Counter value() { return proxy->value(); }
Result result() const { return proxy->result(); }
Result total() const { return proxy->total(); };
- size_t size() const { return proxy->size(); }
+ size_type size() const { return proxy->size(); }
std::string str() const { return proxy->str(); }
bool zero() const { return proxy->zero(); }
Stat *stat;
/** The index to access in the parent VectorBase. */
- int index;
+ off_type index;
public:
/**
* @param p The params to use.
* @param i The index to access.
*/
- ScalarProxy(Stat *s, int i)
+ ScalarProxy(Stat *s, off_type i)
: stat(s), index(i)
{
assert(stat);
* Return the number of elements, always 1 for a scalar.
* @return 1.
*/
- size_t size() const { return 1; }
+ size_type size() const { return 1; }
/**
* This stat has no state. Nothing to reset
protected:
/** The storage of this stat. */
Storage *storage;
- size_t _size;
+ size_type _size;
/** The parameters for this stat. */
Params params;
* @param index The vector index to access.
* @return The storage object at the given index.
*/
- Storage *data(int index) { return &storage[index]; }
+ Storage *data(off_type index) { return &storage[index]; }
/**
* Retrieve a const pointer to the storage.
* @param index The vector index to access.
* @return A const pointer to the storage object at the given index.
*/
- const Storage *data(int index) const { return &storage[index]; }
+ const Storage *data(off_type index) const { return &storage[index]; }
void
- doInit(int s)
+ doInit(size_type s)
{
assert(s > 0 && "size must be positive!");
assert(!storage && "already initialized");
char *ptr = new char[_size * sizeof(Storage)];
storage = reinterpret_cast<Storage *>(ptr);
- for (int i = 0; i < _size; ++i)
+ for (off_type i = 0; i < _size; ++i)
new (&storage[i]) Storage(params);
setInit();
value(VCounter &vec) const
{
vec.resize(size());
- for (int i = 0; i < size(); ++i)
+ for (off_type i = 0; i < size(); ++i)
vec[i] = data(i)->value(params);
}
result(VResult &vec) const
{
vec.resize(size());
- for (int i = 0; i < size(); ++i)
+ for (off_type i = 0; i < size(); ++i)
vec[i] = data(i)->result(params);
}
total() const
{
Result total = 0.0;
- for (int i = 0; i < size(); ++i)
+ for (off_type i = 0; i < size(); ++i)
total += data(i)->result(params);
return total;
}
/**
* @return the number of elements in this vector.
*/
- size_t size() const { return _size; }
+ size_type size() const { return _size; }
bool
zero() const
{
- for (int i = 0; i < size(); ++i)
+ for (off_type i = 0; i < size(); ++i)
if (data(i)->zero())
return false;
return true;
void
reset()
{
- for (int i = 0; i < size(); ++i)
+ for (off_type i = 0; i < size(); ++i)
data(i)->reset();
}
if (!storage)
return;
- for (int i = 0; i < _size; ++i)
+ for (off_type i = 0; i < _size; ++i)
data(i)->~Storage();
delete [] reinterpret_cast<char *>(storage);
}
* @return A reference of the stat.
*/
Proxy
- operator[](int index)
+ operator[](off_type index)
{
assert (index >= 0 && index < size());
return Proxy(this, index);
{
private:
Stat *stat;
- int offset;
- int len;
+ off_type offset;
+ size_type len;
private:
mutable VResult vec;
typename Stat::Storage *
- data(int index)
+ data(off_type index)
{
assert(index < len);
return stat->data(offset + index);
}
const typename Stat::Storage *
- data(int index) const
+ data(off_type index) const
{
assert(index < len);
return const_cast<Stat *>(stat)->data(offset + index);
{
vec.resize(size());
- for (int i = 0; i < size(); ++i)
+ for (off_type i = 0; i < size(); ++i)
vec[i] = data(i)->result(stat->params);
return vec;
total() const
{
Result total = 0;
- for (int i = 0; i < size(); ++i)
+ for (off_type i = 0; i < size(); ++i)
total += data(i)->result(stat->params);
return total;
}
public:
- VectorProxy(Stat *s, int o, int l)
+ VectorProxy(Stat *s, off_type o, size_type l)
: stat(s), offset(o), len(l)
{
}
}
ScalarProxy<Stat>
- operator[](int index)
+ operator[](off_type index)
{
assert (index >= 0 && index < size());
return ScalarProxy<Stat>(stat, offset + index);
}
- size_t size() const { return len; }
+ size_type size() const { return len; }
/**
* This stat has no state. Nothing to reset.
friend class VectorProxy<Vector2dBase<Storage> >;
protected:
- size_t x;
- size_t y;
- size_t _size;
+ size_type x;
+ size_type y;
+ size_type _size;
Storage *storage;
Params params;
protected:
- Storage *data(int index) { return &storage[index]; }
- const Storage *data(int index) const { return &storage[index]; }
+ Storage *data(off_type index) { return &storage[index]; }
+ const Storage *data(off_type index) const { return &storage[index]; }
void
- doInit(int _x, int _y)
+ doInit(size_type _x, size_type _y)
{
assert(_x > 0 && _y > 0 && "sizes must be positive!");
assert(!storage && "already initialized");
char *ptr = new char[_size * sizeof(Storage)];
storage = reinterpret_cast<Storage *>(ptr);
- for (int i = 0; i < _size; ++i)
+ for (off_type i = 0; i < _size; ++i)
new (&storage[i]) Storage(params);
setInit();
if (!storage)
return;
- for (int i = 0; i < _size; ++i)
+ for (off_type i = 0; i < _size; ++i)
data(i)->~Storage();
delete [] reinterpret_cast<char *>(storage);
}
void
update(Vector2dData *newdata)
{
- int size = this->size();
+ size_type size = this->size();
newdata->cvec.resize(size);
- for (int i = 0; i < size; ++i)
+ for (off_type i = 0; i < size; ++i)
newdata->cvec[i] = data(i)->value(params);
}
- std::string ysubname(int i) const { return (*this->y_subnames)[i]; }
+ std::string ysubname(off_type i) const { return (*this->y_subnames)[i]; }
Proxy
- operator[](int index)
+ operator[](off_type index)
{
- int offset = index * y;
+ off_type offset = index * y;
assert (index >= 0 && offset + index < size());
return Proxy(this, offset, y);
}
- size_t
+ size_type
size() const
{
return _size;
{
return data(0)->zero();
#if 0
- for (int i = 0; i < size(); ++i)
+ for (off_type i = 0; i < size(); ++i)
if (!data(i)->zero())
return false;
return true;
void
reset()
{
- for (int i = 0; i < size(); ++i)
+ for (off_type i = 0; i < size(); ++i)
data(i)->reset();
}
/** The number of entries in each bucket. */
Counter bucket_size;
/** The number of buckets. Equal to (max-min)/bucket_size. */
- int size;
+ size_type size;
};
enum { fancy = false };
else if (val > params.max)
overflow += number;
else {
- size_t index = std::floor((val - params.min) / params.bucket_size);
+ size_type index =
+ (size_type)std::floor((val - params.min) / params.bucket_size);
assert(index < size(params));
cvec[index] += number;
}
* @return the number of buckets.
* @todo Is it faster to return the size from the parameters?
*/
- size_t size(const Params &) const { return cvec.size(); }
+ size_type size(const Params &) const { return cvec.size(); }
/**
* Returns true if any calls to sample have been made.
data->underflow = underflow;
data->overflow = overflow;
data->cvec.resize(params.size);
- for (int i = 0; i < params.size; ++i)
+ for (off_type i = 0; i < params.size; ++i)
data->cvec[i] = cvec[i];
data->sum = sum;
underflow = 0;
overflow = 0;
- int size = cvec.size();
- for (int i = 0; i < size; ++i)
+ size_type size = cvec.size();
+ for (off_type i = 0; i < size; ++i)
cvec[i] = Counter();
sum = Counter();
* Return the number of entries in this stat, 1
* @return 1.
*/
- size_t size(const Params &) const { return 1; }
+ size_type size(const Params &) const { return 1; }
/**
* Return true if no samples have been added.
* Return the number of entries, in this case 1.
* @return 1.
*/
- size_t size(const Params ¶ms) const { return 1; }
+ size_type size(const Params ¶ms) const { return 1; }
/**
* Return true if no samples have been added.
* Return the number of entries in this stat.
* @return The number of entries.
*/
- size_t size() const { return data()->size(params); }
+ size_type size() const { return data()->size(params); }
/**
* Return true if no samples have been added.
* @return True if there haven't been any samples.
protected:
Storage *storage;
- size_t _size;
+ size_type _size;
Params params;
protected:
Storage *
- data(int index)
+ data(off_type index)
{
return &storage[index];
}
const Storage *
- data(int index) const
+ data(off_type index) const
{
return &storage[index];
}
void
- doInit(int s)
+ doInit(size_type s)
{
assert(s > 0 && "size must be positive!");
assert(!storage && "already initialized");
char *ptr = new char[_size * sizeof(Storage)];
storage = reinterpret_cast<Storage *>(ptr);
- for (int i = 0; i < _size; ++i)
+ for (off_type i = 0; i < _size; ++i)
new (&storage[i]) Storage(params);
setInit();
if (!storage)
return ;
- for (int i = 0; i < _size; ++i)
+ for (off_type i = 0; i < _size; ++i)
data(i)->~Storage();
delete [] reinterpret_cast<char *>(storage);
}
- Proxy operator[](int index);
+ Proxy operator[](off_type index);
- size_t
+ size_type
size() const
{
return _size;
{
return false;
#if 0
- for (int i = 0; i < size(); ++i)
+ for (off_type i = 0; i < size(); ++i)
if (!data(i)->zero(params))
return false;
return true;
void
reset()
{
- for (int i = 0; i < size(); ++i)
+ for (off_type i = 0; i < size(); ++i)
data(i)->reset();
}
void
update(VectorDistData *base)
{
- int size = this->size();
+ size_type size = this->size();
base->data.resize(size);
- for (int i = 0; i < size; ++i) {
+ for (off_type i = 0; i < size; ++i) {
base->data[i].fancy = Storage::fancy;
data(i)->update(&(base->data[i]), params);
}
{
private:
Stat *stat;
- int index;
+ off_type index;
protected:
typename Stat::Storage *data() { return stat->data(index); }
const typename Stat::Storage *data() const { return stat->data(index); }
public:
- DistProxy(Stat *s, int i)
+ DistProxy(Stat *s, off_type i)
: stat(s), index(i)
{}
data()->sample(v, n, stat->params);
}
- size_t
+ size_type
size() const
{
return 1;
template <class Storage>
inline typename VectorDistBase<Storage>::Proxy
-VectorDistBase<Storage>::operator[](int index)
+VectorDistBase<Storage>::operator[](off_type index)
{
assert (index >= 0 && index < size());
return typename VectorDistBase<Storage>::Proxy(this, index);
#if 0
template <class Storage>
Result
-VectorDistBase<Storage>::total(int index) const
+VectorDistBase<Storage>::total(off_type index) const
{
- int total = 0;
- for (int i = 0; i < x_size(); ++i)
+ Result total = 0;
+ for (off_type i = 0; i < x_size(); ++i)
total += data(i)->result(stat->params);
}
#endif
* Return the number of nodes in the subtree starting at this node.
* @return the number of nodes in this subtree.
*/
- virtual size_t size() const = 0;
+ virtual size_type size() const = 0;
/**
* Return the result vector of this subtree.
* @return The result vector of this subtree.
virtual Result total() const { return data->result(); };
- virtual size_t size() const { return 1; }
+ virtual size_type size() const { return 1; }
/**
*
return proxy.result();
}
- virtual size_t
+ virtual size_type
size() const
{
return 1;
virtual const VResult &result() const { return data->result(); }
virtual Result total() const { return data->total(); };
- virtual size_t size() const { return data->size(); }
+ virtual size_type size() const { return data->size(); }
virtual std::string str() const { return data->name; }
};
ConstNode(T s) : vresult(1, (Result)s) {}
const VResult &result() const { return vresult; }
virtual Result total() const { return vresult[0]; };
- virtual size_t size() const { return 1; }
+ virtual size_type size() const { return 1; }
virtual std::string str() const { return to_string(vresult[0]); }
};
virtual Result
total() const
{
- int size = this->size();
+ size_type size = this->size();
Result tmp = 0;
- for (int i = 0; i < size; i++)
+ for (off_type i = 0; i < size; i++)
tmp += vresult[i];
return tmp;
}
- virtual size_t size() const { return vresult.size(); }
+ virtual size_type size() const { return vresult.size(); }
virtual std::string
str() const
{
- int size = this->size();
+ size_type size = this->size();
std::string tmp = "(";
- for (int i = 0; i < size; i++)
+ for (off_type i = 0; i < size; i++)
tmp += csprintf("%s ",to_string(vresult[i]));
tmp += ")";
return tmp;
result() const
{
const VResult &lvec = l->result();
- int size = lvec.size();
+ size_type size = lvec.size();
assert(size > 0);
vresult.resize(size);
Op op;
- for (int i = 0; i < size; ++i)
+ for (off_type i = 0; i < size; ++i)
vresult[i] = op(lvec[i]);
return vresult;
{
const VResult &vec = this->result();
Result total = 0;
- for (int i = 0; i < size(); i++)
+ for (off_type i = 0; i < size(); i++)
total += vec[i];
return total;
}
- virtual size_t size() const { return l->size(); }
+ virtual size_type size() const { return l->size(); }
virtual std::string
str() const
vresult.resize(1);
vresult[0] = op(lvec[0], rvec[0]);
} else if (lvec.size() == 1) {
- int size = rvec.size();
+ size_type size = rvec.size();
vresult.resize(size);
- for (int i = 0; i < size; ++i)
+ for (off_type i = 0; i < size; ++i)
vresult[i] = op(lvec[0], rvec[i]);
} else if (rvec.size() == 1) {
- int size = lvec.size();
+ size_type size = lvec.size();
vresult.resize(size);
- for (int i = 0; i < size; ++i)
+ for (off_type i = 0; i < size; ++i)
vresult[i] = op(lvec[i], rvec[0]);
} else if (rvec.size() == lvec.size()) {
- int size = rvec.size();
+ size_type size = rvec.size();
vresult.resize(size);
- for (int i = 0; i < size; ++i)
+ for (off_type i = 0; i < size; ++i)
vresult[i] = op(lvec[i], rvec[i]);
}
{
const VResult &vec = this->result();
Result total = 0;
- for (int i = 0; i < size(); i++)
+ for (off_type i = 0; i < size(); i++)
total += vec[i];
return total;
}
- virtual size_t
+ virtual size_type
size() const
{
- int ls = l->size();
- int rs = r->size();
+ size_type ls = l->size();
+ size_type rs = r->size();
if (ls == 1) {
return rs;
} else if (rs == 1) {
result() const
{
const VResult &lvec = l->result();
- int size = lvec.size();
+ size_type size = lvec.size();
assert(size > 0);
vresult[0] = 0.0;
Op op;
- for (int i = 0; i < size; ++i)
+ for (off_type i = 0; i < size; ++i)
vresult[0] = op(vresult[0], lvec[i]);
return vresult;
total() const
{
const VResult &lvec = l->result();
- int size = lvec.size();
+ size_type size = lvec.size();
assert(size > 0);
Result vresult = 0.0;
Op op;
- for (int i = 0; i < size; ++i)
+ for (off_type i = 0; i < size; ++i)
vresult = op(vresult, lvec[i]);
return vresult;
}
- virtual size_t size() const { return 1; }
+ virtual size_type size() const { return 1; }
virtual std::string
str() const
* @return A reference to this stat.
*/
Vector &
- init(size_t size)
+ init(size_type size)
{
this->doInit(size);
return *this;
* @return A reference to this stat.
*/
AverageVector &
- init(size_t size)
+ init(size_type size)
{
this->doInit(size);
return *this;
{
public:
Vector2d &
- init(size_t x, size_t y)
+ init(size_type x, size_type y)
{
this->doInit(x, y);
return *this;
this->params.min = min;
this->params.max = max;
this->params.bucket_size = bkt;
- this->params.size = (int)rint((max - min) / bkt + 1.0);
+ this->params.size = (size_type)rint((max - min) / bkt + 1.0);
this->doInit();
return *this;
}
* @return A reference to this distribution.
*/
VectorDistribution &
- init(int size, Counter min, Counter max, Counter bkt)
+ init(size_type size, Counter min, Counter max, Counter bkt)
{
this->params.min = min;
this->params.max = max;
this->params.bucket_size = bkt;
- this->params.size = (int)rint((max - min) / bkt + 1.0);
+ this->params.size = rint((max - min) / bkt + 1.0);
this->doInit(size);
return *this;
}
* @return A reference to this distribution.
*/
VectorStandardDeviation &
- init(int size)
+ init(size_type size)
{
this->doInit(size);
return *this;
* @return A reference to this distribution.
*/
VectorAverageDeviation &
- init(int size)
+ init(size_type size)
{
this->doInit(size);
return *this;
/**
* Return the number of elements in the tree.
*/
- size_t size() const;
+ size_type size() const;
bool check() const { return true; }
virtual bool zero() const { return s.zero(); }
virtual void reset() { s.reset(); }
- virtual size_t size() const { return s.size(); }
+ virtual size_type size() const { return s.size(); }
virtual const VResult &
result() const
public:
FormulaNode(const Formula &f) : formula(f) {}
- virtual size_t size() const { return formula.size(); }
+ virtual size_type size() const { return formula.size(); }
virtual const VResult &result() const { formula.result(vec); return vec; }
virtual Result total() const { return formula.total(); }
void
VectorPrint::operator()(std::ostream &stream) const
{
- int _size = vec.size();
+ size_type _size = vec.size();
Result _total = 0.0;
if (flags & (pdf | cdf)) {
- for (int i = 0; i < _size; ++i) {
+ for (off_type i = 0; i < _size; ++i) {
_total += vec[i];
}
}
print.value = vec[0];
print(stream);
} else if (!compat) {
- for (int i = 0; i < _size; ++i) {
+ for (off_type i = 0; i < _size; ++i) {
if (havesub && (i >= subnames.size() || subnames[i].empty()))
continue;
Result _cdf = 0.0;
if (flags & dist) {
ccprintf(stream, "%s.start_dist\n", name);
- for (int i = 0; i < _size; ++i) {
+ for (off_type i = 0; i < _size; ++i) {
print.name = havesub ? subnames[i] : to_string(i);
print.desc = subdescs.empty() ? desc : subdescs[i];
print.flags |= __substat;
}
ccprintf(stream, "%s.end_dist\n", name);
} else {
- for (int i = 0; i < _size; ++i) {
+ for (off_type i = 0; i < _size; ++i) {
if (havesub && subnames[i].empty())
continue;
Counter min;
Counter max;
Counter bucket_size;
- int size;
+ size_type size;
bool fancy;
void operator()(ostream &stream) const;
Result total = 0.0;
total += underflow;
- for (int i = 0; i < size; ++i)
+ for (off_type i = 0; i < size; ++i)
total += vec[i];
total += overflow;
}
if (!compat) {
- for (int i = 0; i < size; ++i) {
+ for (off_type i = 0; i < size; ++i) {
stringstream namestr;
namestr << name;
print.flags = flags | __substat;
- for (int i = 0; i < size; ++i) {
+ for (off_type i = 0; i < size; ++i) {
if ((flags & nozero && vec[i] == 0.0) ||
(flags & nonan && isnan(vec[i])))
continue;
if (noOutput(data))
return;
- int size = data.size();
+ size_type size = data.size();
VectorPrint print;
print.name = data.name;
print.total = data.total();
if (!data.subnames.empty()) {
- for (int i = 0; i < size; ++i) {
+ for (off_type i = 0; i < size; ++i) {
if (!data.subnames[i].empty()) {
print.subnames = data.subnames;
print.subnames.resize(size);
- for (int i = 0; i < size; ++i) {
+ for (off_type i = 0; i < size; ++i) {
if (!data.subnames[i].empty() &&
!data.subdescs[i].empty()) {
print.subdescs = data.subdescs;
print.precision = data.precision;
if (!data.subnames.empty()) {
- for (int i = 0; i < data.x; ++i)
+ for (off_type i = 0; i < data.x; ++i)
if (!data.subnames[i].empty())
havesub = true;
}
VResult tot_vec(data.y);
Result super_total = 0.0;
- for (int i = 0; i < data.x; ++i) {
+ for (off_type i = 0; i < data.x; ++i) {
if (havesub && (i >= data.subnames.size() || data.subnames[i].empty()))
continue;
- int iy = i * data.y;
+ off_type iy = i * data.y;
VResult yvec(data.y);
Result total = 0.0;
- for (int j = 0; j < data.y; ++j) {
+ for (off_type j = 0; j < data.y; ++j) {
yvec[j] = data.cvec[iy + j];
tot_vec[j] += yvec[j];
total += yvec[j];
print.underflow = data.data.underflow;
print.overflow = data.data.overflow;
print.vec.resize(data.data.cvec.size());
- for (int i = 0; i < print.vec.size(); ++i)
+ for (off_type i = 0; i < print.vec.size(); ++i)
print.vec[i] = (Result)data.data.cvec[i];
print.sum = data.data.sum;
print.squares = data.data.squares;
if (noOutput(data))
return;
- for (int i = 0; i < data.size(); ++i) {
+ for (off_type i = 0; i < data.size(); ++i) {
DistPrint print;
print.name = data.name + "_" +
print.underflow = data.data[i].underflow;
print.overflow = data.data[i].overflow;
print.vec.resize(data.data[i].cvec.size());
- for (int j = 0; j < print.vec.size(); ++j)
+ for (off_type j = 0; j < print.vec.size(); ++j)
print.vec[j] = (Result)data.data[i].cvec[j];
print.sum = data.data[i].sum;
print.squares = data.data[i].squares;