Exemplo n.º 1
0
        public FrozenSetCollection union([NotNull] params object[] /*!*/ sets)
        {
            SetStorage res = _items.Clone();

            foreach (object set in sets)
            {
                res.UnionUpdate(SetStorage.GetItems(set));
            }

            return(Make(res));
        }
Exemplo n.º 2
0
        public SetCollection intersection([NotNull] params object[] /*!*/ sets)
        {
            Debug.Assert(sets != null);

            if (sets.Length == 0)
            {
                return(copy());
            }

            SetStorage res = _items;

            foreach (object set in sets)
            {
                SetStorage items, x = res, y;
                if (SetStorage.GetItems(set, out items))
                {
                    y = items;
                    SetStorage.SortBySize(ref x, ref y);

                    if (object.ReferenceEquals(x, items) || object.ReferenceEquals(x, _items))
                    {
                        x = x.Clone();
                    }
                }
                else
                {
                    y = items;
                    SetStorage.SortBySize(ref x, ref y);

                    if (object.ReferenceEquals(x, _items))
                    {
                        x = x.Clone();
                    }
                }
                x.IntersectionUpdate(y);
                res = x;
            }

            Debug.Assert(!object.ReferenceEquals(res, _items));
            return(Make(res));
        }
Exemplo n.º 3
0
 public SetCollection copy()
 {
     return(Make(_items.Clone()));
 }