本文整理汇总了C++中std::vector::unitRequirement方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::unitRequirement方法的具体用法?C++ vector::unitRequirement怎么用?C++ vector::unitRequirement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::vector
的用法示例。
在下文中一共展示了vector::unitRequirement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recurseForUnitTime
bool RequirementGroup::recurseForUnitTime(int &latestTime, std::vector<Requirement>::iterator currentRequirement, int currentStartTime, int currentEndTime, std::set<Unit> ¤tUnits)
{
// If we have reached the end we have found a time, save it and return
if(currentRequirement == mUnitRequirements.end())
{
latestTime = currentStartTime;
return true;
}
assert(currentRequirement->unitRequirement());
// get a selection of free times for this requirement
const std::map<int, int> &unitTimes = currentRequirement->earliestUnitTime(currentStartTime, currentEndTime, currentUnits);
// For each one
for(std::map<int, int>::const_iterator it = unitTimes.begin(); it != unitTimes.end(); ++it)
{
currentUnits.insert(currentRequirement->getUnit());
int newEndTime = it->second;
if(newEndTime != Requirement::maxTime)
newEndTime += it->first;
// go to the next requirement with these times to see if it is suitable for the rest too
if(recurseForUnitTime(latestTime, ++(std::vector<Requirement>::iterator(currentRequirement)), it->first, newEndTime, currentUnits))
return true;
currentUnits.erase(currentRequirement->getUnit());
}
return false;
}