Пример #1
0
        public void TestIfIntersectWokscorrectly()
        {
            var firstList = new List <string>()
            {
                "alabala",
                "gruhgruh",
                "tintirimintiri",
                "ivichka e vyrhyt",
                "koki"
            };
            var secondList = new List <string>()
            {
                "trilalal",
                "tophrop",
                "trimtirim",
                "ivichka e vyrhyt",
                "koki"
            };


            var firstSet  = new CustomHashSet <string>(firstList);
            var secondSet = new CustomHashSet <string>(secondList);

            var resultList = firstSet.Intersect(secondList);

            var resultSet = firstSet.Intersect(secondSet);

            foreach (var entry in resultList)
            {
                var result = resultSet.Contains(entry);
                Assert.AreEqual(true, result);
            }

            Assert.AreEqual(resultList.Count(), resultSet.Count);
        }
Пример #2
0
        public static void Main()
        {
            CustomHashSet<int> firstSet = new CustomHashSet<int>();

            for (int i = 0; i < 20; i++)
            {
                firstSet.Add(i);
            }

            CustomHashSet<int> secondSet = new CustomHashSet<int>();

            for (int i = 10; i < 30; i++)
            {
                secondSet.Add(i);
            }

            CustomHashSet<int> resultUnion = firstSet.Intersect(secondSet);

            foreach (var item in resultUnion)
            {
                Console.WriteLine(item);
            }
        }
Пример #3
0
        public void TestIfIntersectWokscorrectly()
        {
            var firstList = new List<string>()
            {
                "alabala",
                "gruhgruh",
                "tintirimintiri",
                "ivichka e vyrhyt",
                "koki"
            };
            var secondList = new List<string>()
            {
                "trilalal",
                "tophrop",
                "trimtirim",
                "ivichka e vyrhyt",
                "koki"
            };

            var firstSet = new CustomHashSet<string>(firstList);
            var secondSet = new CustomHashSet<string>(secondList);

            var resultList = firstSet.Intersect(secondList);

            var resultSet = firstSet.Intersect(secondSet);

            foreach (var entry in resultList)
            {
                var result = resultSet.Contains(entry);
                Assert.AreEqual(true, result);
            }

            Assert.AreEqual(resultList.Count(), resultSet.Count);
        }