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


C# Sequence.CompareTo方法代码示例

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


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

示例1: testCompareTo

        public void testCompareTo() {
            var lowScore = new Sequence();
            lowScore.Add("A", 1d);
            lowScore.Add("B", 2d);
            lowScore.Add("C", 3d);

            var highScore = new Sequence();
            lowScore.Add("A", 7d);
            lowScore.Add("B", 8d);
            lowScore.Add("C", 9d);


            Assert.AreEqual(-1, lowScore.CompareTo(highScore));
            Assert.AreEqual(1, highScore.CompareTo(lowScore));
            Assert.AreEqual(0, highScore.CompareTo(highScore));
        }
开发者ID:lovethisgame,项目名称:SharpNL,代码行数:16,代码来源:SequenceTest.cs

示例2: FindSmallerSequence

        public static void FindSmallerSequence(List<string> keywords, string filename, ref int start, ref int end)
        {
            int keywordsCount = 0;
            Sequence solution = new Sequence(0, int.MaxValue);
            List<int> kwi = new List<int>();
            QueueHashtable q = new QueueHashtable(keywords);

            using (FileStream fs = File.OpenRead(filename))
            {
                while (fs.Position < fs.Length)
                {
                    char c = (char) fs.ReadByte();
                    string currentWord = "";
                    while (c != ' ')
                    {
                        currentWord += c;
                        c = (char) fs.ReadByte();
                    }
                    int i = q.IndexOf(currentWord) - currentWord.Length + 1;
                    if (q.Kw[i].Key != currentWord)
                        continue;
                    if (!q.Kw[i].Value.Any())
                        keywordsCount++;
                    q.Kw[i].Value.Enqueue((int) fs.Position - 1);
                    kwi.Add(i);

                    if (keywordsCount == keywords.Count)
                    {
                        Sequence newSolution = new Sequence(0, 0);
                        while (keywordsCount == keywords.Count)
                        {
                            int index = kwi[0];
                            kwi.RemoveAt(0);
                            newSolution.Start = q.Kw[index].Value.Dequeue();
                            if (!q.Kw[index].Value.Any())
                                keywordsCount--;
                        }
                        newSolution.End = q.Kw[kwi[kwi.Count - 1]].Value.Peek();
                        if (newSolution.CompareTo(solution) < 0)
                        {
                            solution = newSolution;
                            Console.WriteLine(solution.Start + " - " + solution.End);
                            Console.WriteLine("##############");
                        }
                    }
                }
            }

            start = solution.Start;
            end = solution.End;
        }
开发者ID:tgy,项目名称:CSharp,代码行数:51,代码来源:Exo8.cs

示例3: testClone

        public void testClone() {

            var sequence = new Sequence();
            sequence.Add("a", 10);
            sequence.Add("b", 20);

            var copy = sequence.Clone() as Sequence;

            Assert.NotNull(copy);

            Assert.True(sequence.Outcomes.SequenceEqual(copy.Outcomes));
            Assert.True(sequence.Probabilities.SequenceEqual(copy.Probabilities));
            Assert.True(sequence.CompareTo(copy) == 0);
        }
开发者ID:lovethisgame,项目名称:SharpNL,代码行数:14,代码来源:SequenceTest.cs


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