当前位置: 首页>>代码示例>>C#>>正文


C# Coordinate.CompareTo方法代码示例

本文整理汇总了C#中System.Coordinate.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# Coordinate.CompareTo方法的具体用法?C# Coordinate.CompareTo怎么用?C# Coordinate.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Coordinate的用法示例。


在下文中一共展示了Coordinate.CompareTo方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddEdge

        /// <summary>
        /// Adds an edge between the coordinates orig and dest
        /// to this graph.
        /// </summary>
        /// <param name="orig">the edge origin location</param>
        /// <param name="dest">the edge destination location</param>
        /// <returns>the created edge</returns>
        public virtual HalfEdge AddEdge(Coordinate orig, Coordinate dest)
        {
            int cmp = dest.CompareTo(orig);
            // ignore zero-length edges
            if (cmp == 0)
                return null;

            // Attempt to find the edge already in the graph.
            // Return it if found.
            // Otherwise, use a found edge with same origin (if any) to construct new edge. 
            HalfEdge eAdj;
            bool eAdjFound = vertexMap.TryGetValue(orig, out eAdj);
            HalfEdge eSame = null;
            if (eAdjFound)
                eSame = eAdj.Find(dest);
            if (eSame != null)
                return eSame;

            HalfEdge e = Insert(orig, dest, eAdj);
            return e;
        }
开发者ID:ste10k41,项目名称:nettopologysuite,代码行数:28,代码来源:EdgeGraph.cs

示例2: IsValidEdge

 /// <summary>
 /// Test if an the coordinates for an edge form a valid edge (with non-zero length)
 /// </summary>
 /// <param name="orig">The start coordinate</param>
 /// <param name="dest">The end coordinate</param>
 /// <returns><value>true</value> of the edge formed is valid</returns>
 public static bool IsValidEdge(Coordinate orig, Coordinate dest)
 {
     var cmp = dest.CompareTo(orig);
     return cmp != 0;
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:11,代码来源:EdgeGraph.cs

示例3: AddCachedDistanceTimeEntry

        /// <summary>
        /// Adds a new entry to cache, and marks it as unsynced so that next push operation
        /// will send it to the redis server.
        /// </summary>
        /// <param name="a">First coordinate</param>
        /// <param name="b">Second coordinate</param>
        /// <param name="dt">Distance-Time pair</param>
        public void AddCachedDistanceTimeEntry(Coordinate a, Coordinate b, Pair<Int32, Int32> dt)
        {
            // sort coordinates
            if (a.CompareTo(b) > 0)
            {
                Coordinate tmp = a;
                a = b;
                b = tmp;
            }

            // create pair
            Pair<Coordinate, Coordinate> key = new Pair<Coordinate, Coordinate>(a, b);

            AddCachedDistanceTimeEntry(key, dt);
        }
开发者ID:FoundOPS,项目名称:TaskOptimizer,代码行数:22,代码来源:PreprocessedDataCache.cs

示例4: IsIstanceTimeEntryCached

        /// <summary>
        /// Checks if the specified key exists within the cache
        /// </summary>
        /// <param name="a">Coordinate A</param>
        /// <param name="b">Coordinate B</param>
        /// <returns>Boolean indicating whether the key is found</returns>
        public Boolean IsIstanceTimeEntryCached(Coordinate a, Coordinate b)
        {
            // sort coordinates
            if (a.CompareTo(b) > 0)
            {
                Coordinate tmp = a;
                a = b;
                b = tmp;
            }

            // create pair
            Pair<Coordinate, Coordinate> key = new Pair<Coordinate, Coordinate>(a, b);

            return distanceTimeCache.ContainsKey(key);
        }
开发者ID:FoundOPS,项目名称:TaskOptimizer,代码行数:21,代码来源:PreprocessedDataCache.cs

示例5: GetCachedDistanceTime

        /// <summary>
        /// Gets a cached distance-time entry from cache.
        /// </summary>
        /// <param name="a">Coordinate A</param>
        /// <param name="b">Coordinate B</param>
        /// <returns>Distance-Time pair; null if operation fails</returns>
        public Pair<Int32, Int32> GetCachedDistanceTime(Coordinate a, Coordinate b)
        {
            // sort coordinates
            if (a.CompareTo(b) > 0)
            {
                Coordinate tmp = a;
                a = b;
                b = tmp;
            }

            // create pair
            Pair<Coordinate, Coordinate> key = new Pair<Coordinate, Coordinate>(a, b);

            // look for entry
            if (distanceTimeCache.ContainsKey(key))
                return distanceTimeCache[key];
            else
                return null;
        }
开发者ID:FoundOPS,项目名称:TaskOptimizer,代码行数:25,代码来源:PreprocessedDataCache.cs

示例6: TestCompareTo

        public void TestCompareTo()
        {
            Coordinate lowest = new Coordinate(10.0, 100.0, 50.0);
            Coordinate highest = new Coordinate(20.0, 100.0, 50.0);
            Coordinate equalToHighest = new Coordinate(20.0, 100.0, 50.0);
            Coordinate higherStill = new Coordinate(20.0, 200.0, 50.0);

            Assert.AreEqual(-1, lowest.CompareTo(highest));
            Assert.AreEqual(1, highest.CompareTo(lowest));
            Assert.AreEqual(-1, highest.CompareTo(higherStill));
            Assert.AreEqual(0, highest.CompareTo(equalToHighest));
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:12,代码来源:CoordinateTest.cs


注:本文中的System.Coordinate.CompareTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。