示例#1
0
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) {
		char buf[50];
		snprintf(buf,sizeof(buf),"%d",i->second);
		out.write_key_val(i->first, buf);
	}
}
示例#2
0
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;
}
示例#3
0
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;
}
示例#4
0
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;
}
示例#5
0
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;
}
示例#6
0
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;
}
示例#7
0
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;
	}
}
示例#8
0
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);
	}
}