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


C# Set.Intersect方法代码示例

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


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

示例1: Main

        static void Main()
        {
            var setOne = new Set<int>();
            setOne.Add(5);
            setOne.Add(5);
            setOne.Add(5);
            setOne.Add(5);
            setOne.Add(5);
            setOne.Add(5);
            setOne.Add(5);
            setOne.Add(5);
            setOne.Add(5);
            setOne.Add(6);

            var setTwo = new Set<int>();
            setTwo.Add(5);
            setTwo.Add(10);

            Console.WriteLine(setOne);
            Console.WriteLine(setTwo);

            var union = setOne.Union(setTwo);

            Console.WriteLine();
            Console.WriteLine(union);

            var intersect = setOne.Intersect(setTwo);

            Console.WriteLine(intersect);
        }
开发者ID:radenkovn,项目名称:Telerik-Homework,代码行数:30,代码来源:Startup.cs

示例2: Main

        public static void Main(string[] args)
        {
            Set<string> s = new Set<string>();
            s.AddWord("123");
            s.AddWord("234");
            s.AddWord("345");

            Set<string> s2 = new Set<string>();
            s2.AddWord("321");
            s2.AddWord("234");
            s2.AddWord("345");

            Console.WriteLine(s);
            Console.WriteLine();

            Console.WriteLine(s2);
            Console.WriteLine();

            Set<string> s3 = s.Sum(s2);
            Console.WriteLine(s3);

            Set<string> s4 = s.Sub(s2);
            Console.WriteLine(s4);

            Set<string> s5 = s.Intersect(s2);
            Console.WriteLine(s5);
            Console.WriteLine();
        }
开发者ID:ipzPZ121,项目名称:OOP,代码行数:28,代码来源:App.cs

示例3: Main

        public static void Main()
        {
            var set1 = new Set<string>();
            var set2 = new Set<string>();

            set1.Add("one");
            set1.Add("two");
            set1.Add("three");

            set2.Add("three");
            set2.Add("four");

            Console.WriteLine(set1);
            Console.WriteLine(set2);

            Console.WriteLine(set1.Intersect(set2));
            Console.WriteLine(set2.Intersect(set1));

            Console.WriteLine(set1.Union(set2));
            Console.WriteLine(set2.Union(set1));

            set1.Remove("five");
            set1.Remove("two");
            Console.WriteLine(set1);

            Console.WriteLine(set1.Find("one"));
            Console.WriteLine(set1.Find("two"));

            Console.WriteLine(set1.Count);
        }
开发者ID:g-yonchev,项目名称:Data-Structures-and-Algorithms-Homework,代码行数:30,代码来源:Testing.cs

示例4: IntersectTest

 public void IntersectTest()
 {
     Set<int> firstSet = new Set<int>(1, 2, 3, 4, 5);
     Set<int> secondSet = new Set<int>(3, 4, 5, 6, 7);
     Set<int> resultSet = firstSet.Intersect(secondSet);
     Assert.IsTrue(resultSet.Contains(3));
     Assert.IsTrue(resultSet.Contains(4));
     Assert.IsTrue(resultSet.Contains(5));
 }
开发者ID:Kirill-Andreev,项目名称:University,代码行数:9,代码来源:SetTest.cs

示例5: TestIfIntersectIntersectsTwoSets

        public void TestIfIntersectIntersectsTwoSets()
        {
            var setOne = new Set<int>();
            setOne.Add(5);
            setOne.Add(6);

            var setTwo = new Set<int>();
            setTwo.Add(5);
            setTwo.Add(10);

            var intersect = setOne.Intersect(setTwo);

            Assert.AreEqual(2, intersect.Count);
            Assert.AreEqual(false, intersect.Contains(5));
            Assert.AreEqual(true, intersect.Contains(6));
            Assert.AreEqual(true, intersect.Contains(10));
        }
开发者ID:radenkovn,项目名称:Telerik-Homework,代码行数:17,代码来源:SetTests.cs

示例6: CheckConcurrencyControlTokens

        // <summary>
        // Checks:
        // 1) Concurrency token is not defined in this Extent's ElementTypes' derived types
        // 2) Members with concurrency token should not have conditions specified
        // </summary>
        private void CheckConcurrencyControlTokens()
        {
            Debug.Assert(m_viewTarget == ViewTarget.QueryView);
            // Get the token fields for this extent

            var extentType = m_extent.ElementType;
            var tokenMembers = MetadataHelper.GetConcurrencyMembersForTypeHierarchy(extentType, m_edmItemCollection);
            var tokenPaths = new Set<MemberPath>(MemberPath.EqualityComparer);
            foreach (var tokenMember in tokenMembers)
            {
                if (!tokenMember.DeclaringType.IsAssignableFrom(extentType))
                {
                    var message = Strings.ViewGen_Concurrency_Derived_Class(tokenMember.Name, tokenMember.DeclaringType.Name, m_extent);
                    var record = new ErrorLog.Record(ViewGenErrorCode.ConcurrencyDerivedClass, message, m_cellWrappers, String.Empty);
                    ExceptionHelpers.ThrowMappingException(record, m_config);
                }
                tokenPaths.Add(new MemberPath(m_extent, tokenMember));
            }

            if (tokenMembers.Count > 0)
            {
                foreach (var wrapper in m_cellWrappers)
                {
                    var conditionMembers = new Set<MemberPath>(
                        wrapper.OnlyInputCell.CQuery.WhereClause.MemberRestrictions.Select(oneOf => oneOf.RestrictedMemberSlot.MemberPath),
                        MemberPath.EqualityComparer);
                    conditionMembers.Intersect(tokenPaths);
                    if (conditionMembers.Count > 0)
                    {
                        // There is a condition on concurrency tokens. Throw an exception.
                        var builder = new StringBuilder();
                        builder.AppendLine(
                            Strings.ViewGen_Concurrency_Invalid_Condition(
                                MemberPath.PropertiesToUserString(conditionMembers, false), m_extent.Name));
                        var record = new ErrorLog.Record(
                            ViewGenErrorCode.ConcurrencyTokenHasCondition, builder.ToString(), new[] { wrapper }, String.Empty);
                        ExceptionHelpers.ThrowMappingException(record, m_config);
                    }
                }
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:46,代码来源:ViewgenContext.cs

示例7: TestEmptyIntersection

 public void TestEmptyIntersection() {
    var set1 = new Set<int>();
    var set2 = new Set<int>();
    set1.Add(new [] { 1, 2 });
    set2.Add(new [] { 3, 4 });
    var intersection = set1.Intersect(set2);
    Assert.Equals(0, intersection.Count);
 }
开发者ID:ManfredLange,项目名称:csUnit,代码行数:8,代码来源:SetTests.cs

示例8: TestNonIntersection

 public void TestNonIntersection() {
    var set1 = new Set<int>();
    var set2 = new Set<int>();
    set1.Add(new [] { 1, 2 });
    set2.Add(new [] { 2, 3 });
    var intersection = set1.Intersect(set2);
    Assert.Equals(1, intersection.Count);
    Assert.True(intersection.Contains(2));
 }
开发者ID:ManfredLange,项目名称:csUnit,代码行数:9,代码来源:SetTests.cs

示例9: TestIntersection

 public void TestIntersection() {
    var set1 = new Set<int>();
    var set2 = new Set<int>();
    Assert.True(set1.Intersect(set2).IsEmpty);
 }
开发者ID:ManfredLange,项目名称:csUnit,代码行数:5,代码来源:SetTests.cs

示例10: SetIntersectionTest

        public void SetIntersectionTest()
        {
            Set<int> a = new Set<int>();
            for(int i = 0; i < 16; i += 2)
            {
                a.Add(i);
            }

            Set<int> b = new Set<int>();
            for(int i = 0; i < 16; i += 3)
            {
                b.Add(i);
            }

            Set<int> inter = a.Intersect(b);

            Assert.That(inter.Count, Is.EqualTo(3), "A01");
            Assert.That(inter[0], Is.EqualTo(0), "A02");
            Assert.That(inter[1], Is.EqualTo(6), "A03");
            Assert.That(inter[2], Is.EqualTo(12), "A04");
        }
开发者ID:AdrianCNewman,项目名称:mathnet-iridium,代码行数:21,代码来源:SetTest.cs


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