Example #1
0
        public static IPromise <IPromiseEnumerator <T> > Intersect <T>(IPromiseEnumerator <T> left, IPromiseEnumerator <T> right, IEqualityComparer <T> comparer)
        {
            return(CountAlgorithm.Count(left).Then(leftCount => CountAlgorithm.Count(right).Then(rightCount =>
            {
                if (leftCount < rightCount)
                {
                    return Tuple.Create(left, right);
                }

                return Tuple.Create(right, left);
            })).Then(result =>
            {
                var x = result.Item1;
                var y = result.Item2;

                return ToSetAlgorithm.ToSet(x, comparer).Then(lookup => WhereEnumerator.Create(y, q => lookup.Contains(q, comparer)));
            }));
        }
Example #2
0
 public static IPromise <T> Last <T>(IPromiseEnumerator <T> items, Func <T, bool> predicate)
 {
     return(Last(WhereEnumerator.Create(items, predicate)));
 }
Example #3
0
 public static IPromise <T> Single <T>(IPromiseEnumerator <T> items, Func <T, IPromise <bool> > predicate)
 {
     return(Single(WhereEnumerator.Create(items, predicate)));
 }
Example #4
0
 public static IPromise <T> First <T>(IPromiseEnumerator <T> items, Func <T, int, IPromise <bool> > predicate)
 {
     return(First(WhereEnumerator.Create(items, predicate)));
 }
Example #5
0
 public static IPromise <bool> Empty <T>(IPromiseEnumerator <T> items, Func <T, bool> predicate)
 {
     return(Empty(WhereEnumerator.Create(items, predicate)));
 }
 public static IPromise <IPromiseEnumerator <T> > Difference <T>(IPromiseEnumerator <T> left, IPromiseEnumerator <T> right, IEqualityComparer <T> comparer)
 {
     return(ToSetAlgorithm.ToSet(right, comparer).Then(lookup => WhereEnumerator.Create(left, q => !lookup.Contains(q, comparer))));
 }
Example #7
0
 public PromiseGrouping(TKey key, IPromiseEnumerator <Tuple <TKey, TValue> > items, IEqualityComparer <TKey> comparer)
     : base(items.Factory.Value(SelectEnumerator.Create(WhereEnumerator.Create(items, item => comparer.Equals(key, item.Item1)), item => item.Item2)))
 {
     this.Key = key;
 }
 public static IPromise <T> LastOrDefault <T>(IPromiseEnumerator <T> items, Func <T, int, IPromise <bool> > predicate)
 {
     return(LastOrDefault(WhereEnumerator.Create(items, predicate)));
 }
 public static IPromise <T> LastOrDefault <T>(IPromiseEnumerator <T> items, Func <T, bool> predicate, T defaultValue)
 {
     return(LastOrDefault(WhereEnumerator.Create(items, predicate), defaultValue));
 }
Example #10
0
        public static IPromise <IPromiseEnumerator <Result> > GroupJoin <Inner, Outer, Key, Result>(
            IPromiseEnumerator <Inner> inner, IPromiseEnumerator <Outer> outer,
            Func <Inner, int, IPromise <Key> > innerKey, Func <Outer, int, IPromise <Key> > outerKey,
            Func <Outer, IPromiseEnumerable <Inner>, IPromise <Result> > result,
            IEqualityComparer <Key> comparer)
        {
            var innerKeys = SelectEnumerator.Create(inner, (x, i) => innerKey(x, i).Then(v => Tuple.Create(v, x)));

            return(inner.Factory.Value(SelectEnumerator.Create(outer, (x, i) => outerKey(x, i).Then(
                                                                   k => result(x, new PromiseEnumerable <Inner>(
                                                                                   inner.Factory.Value(SelectEnumerator.Create(WhereEnumerator.Create(innerKeys, y => comparer.Equals(y.Item1, k)), y => y.Item2))
                                                                                   ))))));
        }
Example #11
0
 public static IPromise <T> SingleOrDefault <T>(IPromiseEnumerator <T> items, Func <T, bool> predicate)
 {
     return(SingleOrDefault(WhereEnumerator.Create(items, predicate)));
 }
Example #12
0
 public static IPromise <T> SingleOrDefault <T>(IPromiseEnumerator <T> items, Func <T, int, IPromise <bool> > predicate, T defaultValue)
 {
     return(SingleOrDefault(WhereEnumerator.Create(items, predicate), defaultValue));
 }