Esempio n. 1
0
        public static void Main(string[] args)
        {
            var hashset = new HashSetCustom <int>();

            for (int i = 5; i < 15; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    hashset.Add(i);
                }
            }

            System.Console.WriteLine(hashset);
            System.Console.WriteLine(hashset.Count);

            var hashsetTwo = new HashSetCustom <int>();

            for (int i = 0; i < 10; i++)
            {
                hashsetTwo.Add(i);
            }

            Console.WriteLine(hashsetTwo);
            Console.WriteLine(hashsetTwo.Count);
            Console.WriteLine(hashset.IntersectsWith(hashsetTwo));
            Console.WriteLine(hashset.Union(hashsetTwo));
        }
Esempio n. 2
0
        public HashSetCustom <T> Union(HashSetCustom <T> other)
        {
            var result = new HashSetCustom <T>();

            foreach (var myNode in this)
            {
                result.Add(myNode);
            }

            foreach (var otherNode in other)
            {
                result.Add(otherNode);
            }

            return(result);
        }
Esempio n. 3
0
        public HashSetCustom <T> IntersectsWith(HashSetCustom <T> other)
        {
            var result = new HashSetCustom <T>();

            foreach (var myNode in this)
            {
                foreach (var otherNode in other)
                {
                    if (myNode.Equals(otherNode))
                    {
                        result.Add(myNode);
                    }
                }
            }

            return(result);
        }