當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。