Exemplo n.º 1
0
        public IStrictSet <T> Intersect(IStrictSet <T> other)
        {
            other.ValidateNotNull("The set is null!");
            var itemArray = new T[Count];
            var index     = 0;

            foreach (var item in Items)
            {
                if (!other.Contains(item))
                {
                    itemArray[index++] = item;
                }
            }

            foreach (var item in itemArray)
            {
                if (item == null)
                {
                    break;
                }
                Remove(item);
            }

            return(this);
        }
Exemplo n.º 2
0
        public bool IsSubsetOf(IStrictSet <T> other)
        {
            other.ValidateNotNull("The set is null!");
            var isSubset = true;

            foreach (var item in Items)
            {
                if (!other.Contains(item))
                {
                    isSubset = false;
                    break;
                }
            }

            return(isSubset);
        }