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


C# SortedSet.IntersectWith方法代码示例

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


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

示例1: JoinArrays

        static SortedSet<char> JoinArrays(string[] tokens)
        {
            char[] leftArray = tokens[0].ToCharArray();
            char[] rightArray = tokens[1].ToCharArray();
            SortedSet<char> leftSet =
                new SortedSet<char>(leftArray);
            SortedSet<char> rightSet =
                new SortedSet<char>(rightArray);
            SortedSet<char> result =
                new SortedSet<char>();

            result.UnionWith(leftSet);
            result.IntersectWith(leftSet);
            result.IntersectWith(rightSet);
            return result;
        }
开发者ID:YouJinTou,项目名称:SoftUniHomework,代码行数:16,代码来源:ArrayMatcher.cs

示例2: 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

示例3: GetTagScore

 private static double GetTagScore(string tags1, string tags2)
 {
     // Jaccard distance: http://en.wikipedia.org/wiki/Jaccard_index
     if (string.IsNullOrWhiteSpace(tags1) || string.IsNullOrWhiteSpace(tags2)) return 0.0;
     var tagSet1 = new SortedSet<string>(tags1.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries));
     var tagSet2 = new SortedSet<string>(tags2.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries));
     var intersection = new SortedSet<string>(tagSet1);
     intersection.IntersectWith(tagSet2);
     var union = new SortedSet<string>(tagSet1);
     union.UnionWith(tagSet2);
     return (double) intersection.Count/union.Count;
 }
开发者ID:petercerno,项目名称:codetag,代码行数:12,代码来源:EditorForm.cs


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