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


C# SortedSet.SetEquals方法代码示例

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


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

示例1: TestCopyConstructor

        public static void TestCopyConstructor()
        {
            SortedSet<int> sortedSet = new SortedSet<int>();

            List<int> listOfItems = new List<int>();
            for (int i = 0; i < 10000; i++)
            {
                if (!sortedSet.Contains(i))
                {
                    sortedSet.Add(i);
                    listOfItems.Add(i);
                }
            }

            SortedSet<int> newTree1 = new SortedSet<int>(listOfItems);

            Assert.True(newTree1.SetEquals(listOfItems)); //"Expected to be the same set."

            SortedSet<int> newTree2 = new SortedSet<int>(sortedSet);

            Assert.True(sortedSet.SetEquals(newTree2)); //"Expected to be the same set."

            Assert.Equal(sortedSet.Count, newTree1.Count); //"Should be equal."
            Assert.Equal(sortedSet.Count, newTree2.Count); //"Copied tree not the same as base"
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:25,代码来源:SortedSetSpecificTests.cs

示例2: Given1To500ShouldFindFirst500HappyNumbers

            public void Given1To500ShouldFindFirst500HappyNumbers()
            {
                var happy = new HappyCalculator();

                // Source: http://en.wikipedia.org/wiki/Happy_number
                SortedSet<int> first500 = new SortedSet<int>(new int[] { 1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100, 103, 109, 129, 130, 133, 139, 167, 176, 188, 190, 192, 193, 203, 208, 219, 226, 230, 236, 239, 262, 263, 280, 291, 293, 301, 302, 310, 313, 319, 320, 326, 329, 331, 338, 356, 362, 365, 367, 368, 376, 379, 383, 386, 391, 392, 397, 404, 409, 440, 446, 464, 469, 478, 487, 490, 496 });

                happy.CalculateForRange(1, 500);
                SortedSet<int> calculated = happy.GetCalculatedHappyNumbers();

                Assert.IsTrue(first500.SetEquals(calculated));
            }
开发者ID:Ellyll,项目名称:HappyNumbers,代码行数:12,代码来源:HappyCalculatorFacts.cs

示例3: AddAverages

		static async Task AddAverages ()
		{
			var runSets = await ParseInterface.PageQueryWithRetry (() => ParseObject.GetQuery ("RunSet"));
			foreach (var runSet in runSets) {
				if (runSet.ContainsKey ("elapsedTimeAverages") && runSet.ContainsKey ("elapsedTimeVariances")) {
					var averages = runSet.Get<Dictionary<string, object>> ("elapsedTimeAverages");
					var variances = runSet.Get<Dictionary<string, object>> ("elapsedTimeVariances");
					var averagesKeys = new SortedSet<string> (averages.Keys);
					var variancesKeys = new SortedSet<string> (variances.Keys);
					if (averagesKeys.SetEquals (variancesKeys))
						continue;
				}
				await FixRunSet (runSet);
			}
			Console.WriteLine ("got {0} run sets", runSets.Count ());
		}
开发者ID:Aifei-Liu,项目名称:benchmarker,代码行数:16,代码来源:Program.cs

示例4: TestCopyConstructor2

        public static void TestCopyConstructor2()
        {
            SortedSet<int> sortedSet = new SortedSet<int>();

            List<int> listOfItems = new List<int>();
            int c = 0;
            while (sortedSet.Count < 100000)
            {
                c++;
                if (!sortedSet.Contains(50000 - c))
                {
                    sortedSet.Add(50000 - c);
                    listOfItems.Add(50000 - c);
                }
            }

            SortedSet<int> newTree1 = new SortedSet<int>(listOfItems);

            Assert.True(newTree1.SetEquals(listOfItems)); //"Expected to be the same set."

            SortedSet<int> newTree2 = new SortedSet<int>(sortedSet);

            Assert.True(newTree2.SetEquals(sortedSet)); //"Expected to be the same set."

            IEnumerator<int> t1 = sortedSet.GetEnumerator();
            IEnumerator<int> t2 = newTree1.GetEnumerator();
            IEnumerator<int> t3 = newTree2.GetEnumerator();

            while (t1.MoveNext())
            {
                t2.MoveNext();
                t3.MoveNext();

                Assert.Equal(t1.Current, t2.Current); //"Not fully constructed"
                Assert.Equal(t2.Current, t3.Current); //"Not fullu constructed."
            }

            sortedSet.Clear();
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:39,代码来源:SortedSetSpecificTests.cs

示例5: TestIntersectWithSortedSet

        public static void TestIntersectWithSortedSet()
        {
            var sortedSet = new SortedSet<int>();
            int[] itemsToAdd = new int[] { 5, 13, 8, 11, 5, 1, 12, 9, 14, 4, };
            foreach (var item in itemsToAdd)
                sortedSet.Add(item);

            SortedSet<int> meow = new SortedSet<int>();
            int[] itemsToAdd2 = new int[] { 5, 3, 7, 12, 8 };
            foreach (var item in itemsToAdd2)
                meow.Add(item);

            int[] expectedIntersect = new int[] { 5, 12, 8 };
            sortedSet.IntersectWith(meow);
            Assert.True(sortedSet.SetEquals(expectedIntersect)); //"Expected to be the same set."
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:16,代码来源:SortedSetSpecificTests.cs

示例6: TestUnionWithCompare

        public static void TestUnionWithCompare()
        {
            SortedSet<int> sortedSet = new SortedSet<int>();
            HashSet<int> hashSet = new HashSet<int>();
            SortedSet<int> dummy1 = new SortedSet<int>();
            SortedSet<int> dummy2 = new SortedSet<int>();
            int[] dummyNums = new int[]
            {
                10, 29, 45, 93, 8, 50, 14, 27, 66, 3, 86, 41, 96, 34, 62,
                30, 50, 14, 82, 61, 85, 46, 94, 84, 33, 98, 82, 9, 56, 11,
                7, 60, 74, 94, 17, 58, 51, 78, 3, 79, 44, 53, 65, 8, 75,
                43, 58, 19, 22, 97, 69, 3, 11, 44, 17, 64, 34, 61, 59, 9,
                67, 5, 71, 55, 96, 25, 66, 1, 16, 4, 78, 72, 11, 3, 16,
                31, 80, 86, 9, 90, 39, 62, 87, 58, 41, 3, 48, 29, 77, 53,
                24, 90, 18, 93, 11, 39, 81, 9, 12, 49,
            };
            int[] setNums = new int[]
            {
                73, 7, 60, 80, 48, 37, 82, 89, 54, 63, 34, 93, 49, 21, 79,
                79, 99, 59, 66, 68, 23, 70, 46, 83, 16, 0, 64, 85, 20, 92,
                40, 8, 43, 89, 47, 19, 67, 36, 77, 25, 49, 53, 84, 38, 18,
                3, 77, 10, 96, 71, 75, 93, 62, 23, 28, 3, 61, 77, 64, 47,
                73, 96, 68, 62, 23, 25, 50, 60, 74, 59, 11, 62, 81, 40, 18,
                69, 85, 7, 64, 12, 23, 54, 89, 49, 16, 46, 46, 20, 60, 43,
                58, 90, 72, 29, 52, 52, 85, 21, 15, 92,
            };
            foreach (var item in dummyNums)
            {
                dummy1.Add(item);
                dummy2.Add(item);
            }
            foreach (var item in setNums)
            {
                sortedSet.Add(item);
                hashSet.Add(item);
            }

            dummy1.UnionWith(sortedSet);
            dummy2.UnionWith(hashSet);
            int[] expectedUnion = new int[]
            {
                10, 29, 45, 93, 8, 50, 14, 27, 66, 3, 86, 41, 96, 34, 62,
                30, 82, 61, 85, 46, 94, 84, 33, 98, 9, 56, 11, 7, 60, 74,
                17, 58, 51, 78, 79, 44, 53, 65, 75, 43, 19, 22, 97, 69, 64,
                59, 67, 5, 71, 55, 25, 1, 16, 4, 72, 31, 80, 90, 39, 87,
                48, 77, 24, 18, 81, 12, 49, 73, 37, 89, 54, 63, 21, 99, 68,
                23, 70, 83, 0, 20, 92, 40, 47, 36, 38, 28, 52, 15,
            };
            Assert.True(dummy1.SetEquals(expectedUnion)); //"Expected to be the same set."
            Assert.True(dummy2.SetEquals(expectedUnion)); //"Expected to be the same set."
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:51,代码来源:SortedSetSpecificTests.cs

示例7: TestUnionWithSortedSet

        public static void TestUnionWithSortedSet()
        {
            var sortedSet = new SortedSet<int>();
            int[] itemsToAdd = new int[] { 5, 13, 8, 11, 5, 1, 12, 9, 14, 4, };
            foreach (var item in itemsToAdd)
                sortedSet.Add(item);

            SortedSet<int> meow = new SortedSet<int>();
            int[] itemsToAdd2 = new int[] { 5, 3, 7, 12, 0 };
            foreach (var item in itemsToAdd2)
                meow.Add(item);

            List<int> expectedUnion = new List<int>();
            foreach (var item in itemsToAdd)
            {
                if (!expectedUnion.Contains(item))
                    expectedUnion.Add(item);
            }
            foreach (var item in itemsToAdd2)
            {
                if (!expectedUnion.Contains(item))
                    expectedUnion.Add(item);
            }

            sortedSet.UnionWith(meow);
            Assert.True(sortedSet.SetEquals(expectedUnion)); //"Expected to be the same set."
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:27,代码来源:SortedSetSpecificTests.cs

示例8: ChangesMade

        public bool ChangesMade(bool resetChangeLog)
        {
            var massList = new SortedSet<double>();
            var siteList = new SortedSet<char>();
            foreach (var kvp in _currentMasses)
                massList.Add(kvp.Key);
            foreach (var kvp in _currentSites)
                siteList.Add(kvp.Key);

            bool confirmedChanges = !massList.SetEquals(_savedMasses) ||
                                    !siteList.SetEquals(_savedSites);
            if (resetChangeLog)
            {
                _savedMasses = new SortedSet<double>(massList);
                _savedSites = new SortedSet<char>(siteList);
            }
            return confirmedChanges;
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:18,代码来源:UnimodControl.cs

示例9: ContainsSameDigits

 public bool ContainsSameDigits(long num1, long num2)
 {
     var set1 = new SortedSet<char>(num1.ToString().ToList());
       var set2 = new SortedSet<char>(num2.ToString().ToList());
       return set1.SetEquals(set2);
 }
开发者ID:asciamanna,项目名称:ProjectEuler,代码行数:6,代码来源:Problem52.cs

示例10: SetContentsOfCellTest13

 public void SetContentsOfCellTest13()
 {
     Spreadsheet target = new Spreadsheet();
     target.SetContentsOfCell("A1", new Formula("B2").ToString());
     target.SetContentsOfCell("A1", "check");
     SortedSet<string> actual = new SortedSet<string>(target.SetContentsOfCell("B2", "mate"));
     SortedSet<string> expected = new SortedSet<string>() { "B2" };
     Assert.AreEqual(actual.Count, 1);
     Assert.IsTrue(expected.SetEquals(actual));
 }
开发者ID:jam98,项目名称:Spreadsheet,代码行数:10,代码来源:PS4SpreadsheetTest.cs

示例11: SetContentsOfCellTest12

 public void SetContentsOfCellTest12()
 {
     Spreadsheet target = new Spreadsheet();
     SortedSet<string> actual1 = new SortedSet<string>(target.SetContentsOfCell("A1", "=B2 + C3"));
     SortedSet<string> actual2 = new SortedSet<string>(target.SetContentsOfCell("B2", "=D4-1"));
     SortedSet<string> actual3 = new SortedSet<string>(target.SetContentsOfCell("D4", "=F5"));
     SortedSet<string> actual4 = new SortedSet<string>(target.SetContentsOfCell("E6", 2.9.ToString()));
     SortedSet<string> expected1 = new SortedSet<string>() { "A1" };
     SortedSet<string> expected2 = new SortedSet<string>() { "B2", "A1"};
     SortedSet<string> expected3 = new SortedSet<string>() { "D4", "B2", "A1" };
     SortedSet<string> expected4 = new SortedSet<string>() { "E6" };
     Assert.AreEqual(actual1.Count, 1);
     Assert.AreEqual(actual2.Count, 2);
     Assert.AreEqual(actual3.Count, 3);
     Assert.AreEqual(actual4.Count, 1);
     Assert.IsTrue(expected1.SetEquals(actual1));
     Assert.IsTrue(expected2.SetEquals(actual2));
     Assert.IsTrue(expected3.SetEquals(actual3));
     Assert.IsTrue(expected4.SetEquals(actual4));
 }
开发者ID:jam98,项目名称:Spreadsheet,代码行数:20,代码来源:PS4SpreadsheetTest.cs


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