Beispiel #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)));
            }));
        }
 public static IPromise <IPromiseEnumerator <Value> > OrderBy <Key, Value>(IPromiseEnumerator <Value> items, Func <Value, int, IPromise <Key> > key, IComparer <Key> comparer)
 {
     return(CountAlgorithm.Count(items).Then(count =>
                                             OrderByInternal(items.Factory, SelectEnumerator.Create(items, (x, i) => key(x, i).Then(v => Tuple.Create(v, x))), count, comparer)
                                             .Then(i => SelectEnumerator.Create(i, x => x.Item2))));
 }