public FrozenSetCollection union([NotNull] params object[] /*!*/ sets) { SetStorage res = _items.Clone(); foreach (object set in sets) { res.UnionUpdate(SetStorage.GetItems(set)); } return(Make(res)); }
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)); }
public SetCollection copy() { return(Make(_items.Clone())); }