本文整理汇总了C#中City.HasValue方法的典型用法代码示例。如果您正苦于以下问题:C# City.HasValue方法的具体用法?C# City.HasValue怎么用?C# City.HasValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类City
的用法示例。
在下文中一共展示了City.HasValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CountPath
Natural CountPath(City city)
{
if(city.HasValue()) return city.PathCount;
if(visited[city]) {
// a cycle
foreach(City c in visitedCities) {
// if any of the city in the cycle can reach warfare capital, then there's infinite path, otherwise 0
bool reachable = IsReachable(c, lastCity);
if(reachable) return Natural.Infinity;
if(c == city) break;
}
return 0;
}
visited[city] = true;
visitedCities.Push(city);
ICollection<City> neighbours = city.Neighbours;
Natural totalCount = city == lastCity ? 1 : 0;
foreach(City n in neighbours) {
totalCount = (totalCount + CountPath(n)) % MOD;
if(totalCount.IsInfinity()) break;
}
visitedCities.Pop();
visited[city] = false;
city.PathCount = totalCount;
return totalCount;
}