
Hello, Thank you for offering to have a look, here is the code. regards, -dhruva // Starts here #include <stdio.h> #include <iostream> #include <vector> #include <boost/accumulators/accumulators.hpp> #include <boost/accumulators/statistics/stats.hpp> #include <boost/accumulators/statistics/min.hpp> using namespace std; namespace bacc = boost::accumulators; using namespace bacc; typedef struct { size_t _time; double _value; } time_val_t; /* Wrapper class as I cannot modify time_val_t */ class acc_sample { public: time_val_t _data; acc_sample(time_t t = 0, double v = 0.0) { _data._time = t; _data._value = v; } acc_sample(const time_val_t &i) { _data = i; } acc_sample(const acc_sample &i) { _data = i._data; } bool operator < (const acc_sample &rhs) { return _data._value < rhs._data._value; } bool operator > (const acc_sample &rhs) { return _data._value > rhs._data._value; } bool operator == (const acc_sample &rhs) { return _data._value == rhs._data._value; } bool operator != (const acc_sample &rhs) { return _data._value != rhs._data._value; } }; int main(int argc, char *argv[]) { #if 0 acc_sample s1(10, 100); acc_sample s2(11, 101); acc_sample s3(12, 102); if (s1 == s1) cout << "==" << endl; if (s1 < s2) cout << "<" << endl; if (s2 > s1) cout << ">" << endl; #endif accumulator_set< acc_sample, features< tag::min > > acc; return 0; } // Ends here ----- Original Message ----
From: Eric Niebler <eric@boost-consulting.com> To: boost-users@lists.boost.org Sent: Wednesday, 25 February, 2009 10:37:42 AM Subject: Re: [Boost-users] [accumulators] Help required for using UDT as Sample
dhruva wrote:
I have my own data type, time stamp and value. I would like to get the min Sample with corresponding time stamp.
class time_val { public: time_t _time; double _value;
/* I have overloaded operators: <, >, ==, != */ /* Have provided copy constructor */ };
When I try: accumulator_set< time_val, features > acc;
I get a whole lot of compilation errors. Is there any way I can make a UDT as a sample?
That should just work. Can you provide a complete example?
-- Eric Niebler BoostPro Computing http://www.boostpro.com _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/