Beispiel #1
0
        internal Set(IEnumerable <T> items)
        {
            set = SetItem <T> .Empty;

            // TODO: Perf
            foreach (var item in items)
            {
                set = SetModule.Add(set, item, Comparer <T> .Default);
            }
        }
 public IEnumerable <A> FindRange(A keyFrom, A keyTo)
 {
     if (isnull(keyFrom))
     {
         throw new ArgumentNullException(nameof(keyFrom));
     }
     if (isnull(keyTo))
     {
         throw new ArgumentNullException(nameof(keyTo));
     }
     return(default(OrdA).Compare(keyFrom, keyTo) > 0
         ? SetModule.FindRange <OrdA, A>(set, keyTo, keyFrom)
         : SetModule.FindRange <OrdA, A>(set, keyFrom, keyTo));
 }
Beispiel #3
0
        /// <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);
                }
            }
        }
Beispiel #4
0
        /// <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);
                }
            }
        }
 public Option <A> FindOrSuccessor(A key) => SetModule.TryFindOrSuccessor <OrdA, A>(set, key);
 public Option <A> Find(A value) =>
 SetModule.TryFind <OrdA, A>(set, value);
 public SetInternal <OrdA, A> AddOrUpdate(A value) =>
 new SetInternal <OrdA, A>(SetModule.AddOrUpdate <OrdA, A>(set, value));
 public bool Exists(Func <A, bool> pred) =>
 SetModule.Exists(set, pred);
 public SetInternal <OrdB, B> Map <OrdB, B>(Func <A, B> f) where OrdB : struct, Ord <B> =>
 new SetInternal <OrdB, B>(SetModule.Map(set, f));
Beispiel #10
0
 public bool Contains(T value) =>
 SetModule.Contains(set, value, Comparer <T> .Default);
Beispiel #11
0
 public Set <T> Filter(Func <T, bool> pred) =>
 new Set <T>(SetModule.Filter(set, pred));
Beispiel #12
0
 public S Fold <S>(S state, Func <S, T, S> folder) =>
 SetModule.Fold(set, state, folder);
Beispiel #13
0
 public Set <T> Remove(T value) =>
 new Set <T>(SetModule.Remove(set, value, Comparer <T> .Default));
Beispiel #14
0
 public SetInternal <OrdA, A> Remove(A value) =>
 new SetInternal <OrdA, A>(SetModule.Remove <OrdA, A>(set, value));
Beispiel #15
0
 public Set <T> Add(T value) =>
 new Set <T>(SetModule.Add(set, value, Comparer <T> .Default));
Beispiel #16
0
 public S FoldBack <S>(S state, Func <S, A, S> folder) =>
 SetModule.FoldBack(set, state, folder);
Beispiel #17
0
 public Option <T> Find(T value) =>
 SetModule.Find(set, value, Comparer <T> .Default);
Beispiel #18
0
 public SetInternal <OrdA, A> Map(Func <A, A> f) =>
 new SetInternal <OrdA, A>(SetModule.Map(set, f));
Beispiel #19
0
 public SetInternal <OrdA, A> Add(A value) =>
 new SetInternal <OrdA, A>(SetModule.Add <OrdA, A>(set, value));
Beispiel #20
0
 public bool Contains(A value) =>
 SetModule.Contains <OrdA, A>(set, value);
Beispiel #21
0
 public SetInternal <OrdA, A> Filter(Func <A, bool> pred) =>
 new SetInternal <OrdA, A>(SetModule.Filter(set, pred));