internal Set(IEnumerable <T> items) { set = SetItem <T> .Empty; // TODO: Perf foreach (var item in items) { set = SetModule.Add(set, item, Comparer <T> .Default); } }
/// <summary> /// Ctor that takes an initial (distinct) set of items /// </summary> /// <param name="items"></param> internal Set(IEnumerable <T> items, bool checkUniqueness = false) { set = SetItem <T> .Empty; if (checkUniqueness) { foreach (var item in items) { set = SetModule.TryAdd(set, item, Comparer <T> .Default); } } else { foreach (var item in items) { set = SetModule.Add(set, item, Comparer <T> .Default); } } }
/// <summary> /// Ctor that takes an initial (distinct) set of items /// </summary> /// <param name="items"></param> internal SetInternal(IEnumerable <A> items, bool tryAdd) { set = SetItem <A> .Empty; if (tryAdd) { foreach (var item in items) { set = SetModule.TryAdd <OrdA, A>(set, item); } } else { foreach (var item in items) { set = SetModule.Add <OrdA, A>(set, item); } } }
public SetInternal <OrdA, A> Add(A value) => new SetInternal <OrdA, A>(SetModule.Add <OrdA, A>(set, value));
public Set <T> Add(T value) => new Set <T>(SetModule.Add(set, value, Comparer <T> .Default));