我想将多个 boost accumulataor_set 存储在 stl 地图中。
我阅读的所有示例都accumulator_set
用作局部变量:
accumulator_set<int, stats<tag::rolling_mean> > acc(tag::rolling_window::window_size = 5);
acc(1);
acc(2);
acc(3);
cout << rolling_mean(acc);
但是我想存储accumulator_set
在地图中。我试着写这样的代码,但我卡住了:
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]) ;
}
如何accumulator_set
在上面的示例中创建一个并将其(引用或对象)存储在地图中?