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 IStrictSet <T> Differ(IStrictSet <T> other)
        {
            other.ValidateNotNull("The set is null!");
            foreach (var item in other)
            {
                if (Contains(item))
                {
                    Remove(item);
                }
            }

            return(this);
        }
Exemplo n.º 3
0
        public IStrictSet <T> Union(IStrictSet <T> other)
        {
            other.ValidateNotNull("The set is null!");
            foreach (var item in other)
            {
                if (!Contains(item))
                {
                    Add(item);
                }
            }

            return(this);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        public bool IsDisjointWith(IStrictSet <T> other)
        {
            other.ValidateNotNull("The set is null!");
            var disjoint = true;

            foreach (var item in other)
            {
                if (Contains(item))
                {
                    disjoint = false;
                    break;
                }
            }

            return(disjoint);
        }
Exemplo n.º 6
0
 public bool IsEqualWith(IStrictSet <T> other)
 {
     other.ValidateNotNull("the set is null!");
     return(other.IsSubsetOf(this) && IsSubsetOf(other));
 }