Hello,
See this:
class Value {
public:
double _value;
bool _missed;
...................
};
class Feature {
static std::vector<Value, std::allocator<Value> >&
sum_vec(std::vector<Value, std::allocator<Value> >& v, const Value& right) {
if ( !right.getMissed() ) {
v.push_back(right);
}
return v;
}
......................................
};
//main.cpp
std::vector<Value, std::allocator<Value> > vVal;
vVal = std::accumulate( _values.begin(), _values.end(), vVal, Feature::sum_vec ); //1
_mean = std::accumulate( vVal.begin(), vVal.end() ) / vVal.size(); //2
class Value {
public:
double _value;
bool _missed;
...................
};
class Feature {
static std::vector<Value, std::allocator<Value> >&
sum_vec(std::vector<Value, std::allocator<Value> >& v, const Value& right) {
if ( !right.getMissed() ) {
v.push_back(right);
}
return v;
}
......................................
};
//main.cpp
std::vector<Value, std::allocator<Value> > vVal;
vVal = std::accumulate( _values.begin(), _values.end(), vVal, Feature::sum_vec ); //1
_mean = std::accumulate( vVal.begin(), vVal.end() ) / vVal.size(); //2
To copy to clipboard, switch view to plain text mode
//1 return vVal that is a new vector that contains only the values that must be summed; (and it is ok)
//2 doesn't compile, because seems vVal.begin() and vVal.end() are not good; Could anyone correct this, please?
However: this isn't the solution that I wanted; I must call 2 accumulate and push_back into a new vector;
I hope this can be a point to reach my aim
Regards,
Bookmarks