コード例 #1
0
        private static void ExecuteAddCommand(string[] arguments, DictHashSet <int> dictHashSet)
        {
            int  element = int.Parse(arguments[1]);
            bool isAdded = dictHashSet.Add(element);

            AppendLine(isAdded.ToString());
        }
コード例 #2
0
        private static void ExecuteIntersectCommand(string[] arguments, DictHashSet <int> dictHashSet)
        {
            DictHashSet <int> intersectionSet = new DictHashSet <int>();

            for (int i = 1; i < arguments.Length; i++)
            {
                int otherSetElement = int.Parse(arguments[i]);
                intersectionSet.Add(otherSetElement);
            }

            dictHashSet.Intersect(intersectionSet);
        }
コード例 #3
0
        public void Intersect(DictHashSet <T> otherDictHashSet)
        {
            if (otherDictHashSet == null)
            {
                throw new ArgumentNullException();
            }

            DictHashSet <T> intersection = new DictHashSet <T>();

            foreach (T item in otherDictHashSet)
            {
                if (this.Contains(item))
                {
                    intersection.Add(item);
                }
            }

            this.container = intersection.container;
        }