/// <summary> /// Ctor that takes an initial (distinct) set of items /// </summary> /// <param name="items"></param> internal SetInternal(IEnumerable <A> items, SetModuleM.AddOpt option) { set = SetItem <A> .Empty; foreach (var item in items) { set = SetModuleM.Add <OrdA, A>(set, item, option); } }
public SetInternal <OrdA, A> Except(SetInternal <OrdA, A> rhs) { var root = SetItem <A> .Empty; foreach (var item in this) { if (!rhs.Contains(item)) { root = SetModuleM.Add <OrdA, A>(root, item, SetModuleM.AddOpt.TryAdd); } } return(new SetInternal <OrdA, A>(root)); }
public SetInternal <OrdA, A> Intersect(IEnumerable <A> other) { var root = SetItem <A> .Empty; foreach (var item in other) { if (Contains(item)) { root = SetModuleM.Add <OrdA, A>(root, item, SetModuleM.AddOpt.TryAdd); } } return(new SetInternal <OrdA, A>(root)); }
public SetInternal <OrdA, A> Union(IEnumerable <A> other) { if (other == null || !other.Any()) { return(this); } var root = SetItem <A> .Empty; foreach (var item in this) { root = SetModuleM.Add <OrdA, A>(root, item, SetModuleM.AddOpt.TryAdd); } foreach (var item in other) { root = SetModuleM.Add <OrdA, A>(root, item, SetModuleM.AddOpt.TryAdd); } return(new SetInternal <OrdA, A>(root)); }