コード例 #1
0
ファイル: TestGenericSet.cs プロジェクト: anderscui/cslib
        public void TestIntersection()
        {
            GenericSet <int> gs1 = new GenericSet <int>();

            for (int i = 1; i <= 8; i++)
            {
                gs1.Add(i);
            }
            Console.WriteLine(gs1);

            GenericSet <int> gs2 = new GenericSet <int>();

            for (int i = 5; i <= 15; i++)
            {
                gs2.Add(i);
            }
            Console.WriteLine(gs2);

            GenericSet <int> union = gs1.Intersection(gs2);

            Assert.That(union.Size, Is.EqualTo(4));
            Assert.That(union.Contains(15), Is.False);
            Assert.That(union.Contains(1), Is.False);
            Assert.That(union.Contains(5), Is.True);
            Assert.That(union.Contains(8), Is.True);
            Console.WriteLine("Intersection: {0}", union);
        }