本文整理汇总了C#中System.Collections.SortedSet.AddAll方法的典型用法代码示例。如果您正苦于以下问题:C# SortedSet.AddAll方法的具体用法?C# SortedSet.AddAll怎么用?C# SortedSet.AddAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.SortedSet
的用法示例。
在下文中一共展示了SortedSet.AddAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsSequenced
/// <summary>
/// Tests whether a <see cref="Geometry" /> is sequenced correctly.
/// <see cref="LineString" />s are trivially sequenced.
/// <see cref="MultiLineString" />s are checked for correct sequencing.
/// Otherwise, <c>IsSequenced</c> is defined
/// to be <c>true</c> for geometries that are not lineal.
/// </summary>
/// <param name="geom">The <see cref="Geometry" /> to test.</param>
/// <returns>
/// <c>true</c> if the <see cref="Geometry" /> is sequenced or is not lineal.
/// </returns>
public static bool IsSequenced(IGeometry geom)
{
if (!(geom is IMultiLineString))
return true;
IMultiLineString mls = geom as IMultiLineString;
// The nodes in all subgraphs which have been completely scanned
ISet<ICoordinate> prevSubgraphNodes = new SortedSet<ICoordinate>();
ICoordinate lastNode = null;
IList<ICoordinate> currNodes = new List<ICoordinate>();
for (int i = 0; i < mls.NumGeometries; i++)
{
ILineString line = (ILineString) mls.GetGeometryN(i);
ICoordinate startNode = line.GetCoordinateN(0);
ICoordinate endNode = line.GetCoordinateN(line.NumPoints - 1);
/*
* If this linestring is connected to a previous subgraph, geom is not sequenced
*/
if (prevSubgraphNodes.Contains(startNode))
return false;
if (prevSubgraphNodes.Contains(endNode))
return false;
if (lastNode != null && startNode != lastNode)
{
// start new connected sequence
prevSubgraphNodes.AddAll(currNodes);
currNodes.Clear();
}
currNodes.Add(startNode);
currNodes.Add(endNode);
lastNode = endNode;
}
return true;
}