I’d like to store multiple boost accumulataor_set in a stl map.
All the examples I read use accumulator_set as a local variable:
accumulator_set<int, stats<tag::rolling_mean> > acc(tag::rolling_window::window_size = 5);
acc(1);
acc(2);
acc(3);
cout << rolling_mean(acc);
However I want to store accumulator_set in a map. I tried to write code like this, but I got stuck:
map<int, accumulator_set<long, stats<tag::rolling_mean> > > avg;
void update(int id, long data){
if(avg.count(id)==0){
//key doesn't exist in map
avg[id]= ;// How to create acc as in above example and store it in map?
}
accumulator_set<long, stats<tag::rolling_mean> > &acc = avg[id];
acc(data);
}
void read(int id){
cout << rolling_mean(avg[id]) ;
}
How do I create an accumulator_set as in above example and store it(reference or object) in map?
You can use insert():