本文整理汇总了C++中ImportParameter::GetOptimizationMaxWayCount方法的典型用法代码示例。如果您正苦于以下问题:C++ ImportParameter::GetOptimizationMaxWayCount方法的具体用法?C++ ImportParameter::GetOptimizationMaxWayCount怎么用?C++ ImportParameter::GetOptimizationMaxWayCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImportParameter
的用法示例。
在下文中一共展示了ImportParameter::GetOptimizationMaxWayCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetAreas
bool OptimizeAreasLowZoomGenerator::GetAreas(const TypeConfig& typeConfig,
const ImportParameter& parameter,
Progress& progress,
FileScanner& scanner,
const TypeInfoSet& types,
std::vector<std::list<AreaRef> >& areas,
TypeInfoSet& loadedTypes)
{
uint32_t areaCount=0;
size_t collectedAreasCount=0;
loadedTypes=types;
progress.SetAction("Collecting area data to optimize");
scanner.GotoBegin();
scanner.Read(areaCount);
for (uint32_t a=1; a<=areaCount; a++) {
AreaRef area=std::make_shared<Area>();
progress.SetProgress(a,areaCount);
area->Read(typeConfig,
scanner);
if (loadedTypes.IsSet(area->GetType())) {
areas[area->GetType()->GetIndex()].push_back(area);
collectedAreasCount++;
while (collectedAreasCount>parameter.GetOptimizationMaxWayCount() &&
loadedTypes.Size()>1) {
TypeInfoRef victimType;
for (auto &type : loadedTypes) {
if (areas[type->GetIndex()].size()>0 &&
(!victimType ||
areas[type->GetIndex()].size()<areas[victimType->GetIndex()].size())) {
victimType=type;
}
}
assert(victimType);
collectedAreasCount-=areas[victimType->GetIndex()].size();
areas[victimType->GetIndex()].clear();
loadedTypes.Remove(victimType);
}
}
}
progress.Info("Collected "+NumberToString(collectedAreasCount)+" areas for "+NumberToString(loadedTypes.Size())+" types");
return !scanner.HasError();
}