本文整理汇总了C++中Country::get_id方法的典型用法代码示例。如果您正苦于以下问题:C++ Country::get_id方法的具体用法?C++ Country::get_id怎么用?C++ Country::get_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Country
的用法示例。
在下文中一共展示了Country::get_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeConnectedComponents
void Evaluation::computeConnectedComponents()
{
// Do not use 42 here as it might change from outside this file
// Rather obtain the number of countries from Global Settings
int nb_countries = gs->get_global_settings()->get_countries().size();
//bool markedCountries[42]; Must be allocated dinamically
bool* markedCountries = (bool*) malloc (nb_countries * sizeof(bool));
for(int i=0; i<nb_countries; i++)
{
markedCountries[i]=0;
}
stack<Country*> pile;
list<Country*> countries = gs->countries_owned_by(gs->get_current_player());
for (list<Country*>::iterator it = countries.begin(); it!=countries.end(); ++it)
{
markedCountries[(*it)->get_id()]=1;
pile.push(*it);
}
while(!pile.empty()){
Country* elem = pile.top();
pile.pop(); // void
if (markedCountries[elem->get_id()]==0){continue;}
else{
stack<Country*> parcours;
Connected_component* connected_comp = new Connected_component(world_map, gs, probabilities);
parcours.push(elem);
while(!parcours.empty()){
Country* father = parcours.top();
parcours.pop(); // void
if(markedCountries[father->get_id()]==0){continue;}
else{
markedCountries[father->get_id()]=0;
connected_comp->add(father);
set<Country*> sons = (world_map->find(father))->second;
for(set<Country*>::iterator son = sons.begin(); son!=sons.end(); ++son)
{
if(gs->owner(*son) == gs->get_current_player()){
parcours.push(*son);
}
}
}
}
connected_components.push_back(connected_comp);
}
}
}