int sum_cost_str_int_map(const stats::str_int_map &m) { int cost = 0; for (stats::str_int_map::const_iterator i = m.begin(); i != m.end(); ++i) { cost += i->second * unit_types.find(i->first)->cost(); } return cost; }
int sum_str_int_map(const stats::str_int_map& m) { int res = 0; for(stats::str_int_map::const_iterator i = m.begin(); i != m.end(); ++i) { res += i->second; } return res; }
static config write_str_int_map(const stats::str_int_map& m) { config res; for(stats::str_int_map::const_iterator i = m.begin(); i != m.end(); ++i) { res[i->first] = i->second; } return res; }
static config write_str_int_map(const stats::str_int_map& m) { config res; for(stats::str_int_map::const_iterator i = m.begin(); i != m.end(); ++i) { char buf[50]; snprintf(buf,sizeof(buf),"%d",i->second); res[i->first] = buf; } return res; }
int sum_cost_str_int_map(const stats::str_int_map &m) { int cost = 0; for (stats::str_int_map::const_iterator i = m.begin(); i != m.end(); ++i) { const unit_type *t = unit_types.find(i->first); if (!t) { ERR_NG << "Statistics refer to unknown unit type '" << i->first << "'. Discarding." << std::endl; } else { cost += i->second * t->cost(); } } return cost; }
static void merge_str_int_map(stats::str_int_map& a, const stats::str_int_map& b) { for(stats::str_int_map::const_iterator i = b.begin(); i != b.end(); ++i) { a[i->first] += i->second; } }
static void write_str_int_map(config_writer &out, const stats::str_int_map& m) { for(stats::str_int_map::const_iterator i = m.begin(); i != m.end(); ++i) { out.write_key_val(i->first, i->second); } }