Beispiel #1
0
        private static int Compare(OperatorEnumerable lhs, IEnumerable rhs)
        {
            using (var leftIterator = lhs.source.GetEnumerator())
            {
                using (var rightIterator = rhs.Cast <object>().GetEnumerator())
                {
                    while (true)
                    {
                        bool leftHasNext  = leftIterator.MoveNext();
                        bool rightHasNext = rightIterator.MoveNext();
                        if (!leftHasNext && !rightHasNext)
                        {
                            return(0);
                        }
                        if (!rightHasNext)
                        {
                            return(1);
                        }
                        if (!leftHasNext)
                        {
                            return(-1);
                        }
                        int comparison = Comparer <object> .Default.Compare(leftIterator.Current, rightIterator.Current);

                        if (comparison != 0)
                        {
                            return(comparison);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public static OperatorEnumerable operator ^(OperatorEnumerable lhs, uint rhs)
        {
            if (rhs == 0)
            {
                return(Enumerable.Empty <object>().Evil());
            }
            OperatorEnumerable result = lhs;

            for (int i = 1; i < rhs; i++)
            {
                result = result * lhs;
            }
            return(result | FlattenTuples);
        }
Beispiel #3
0
        private static IEnumerable <OperatorEnumerable> Batch(OperatorEnumerable source, int size)
        {
            List <object> currentList = new List <object>(size);

            foreach (var item in source)
            {
                currentList.Add(item);
                if (currentList.Count == size)
                {
                    yield return(new OperatorEnumerable(currentList));

                    currentList = new List <object>(size);
                }
            }
        }
 private static IEnumerable<OperatorEnumerable> Batch(OperatorEnumerable source, int size)
 {
     List<object> currentList = new List<object>(size);
     foreach (var item in source)
     {
         currentList.Add(item);
         if (currentList.Count == size)
         {
             yield return new OperatorEnumerable(currentList);
             currentList = new List<object>(size);
         }
     }
 }
 private static int Compare(OperatorEnumerable lhs, IEnumerable rhs)
 {
     using (var leftIterator = lhs.source.GetEnumerator())
     {
         using (var rightIterator = rhs.Cast<object>().GetEnumerator())
         {
             while (true)
             {
                 bool leftHasNext = leftIterator.MoveNext();
                 bool rightHasNext = rightIterator.MoveNext();
                 if (!leftHasNext && !rightHasNext)
                 {
                     return 0;
                 }
                 if (!rightHasNext)
                 {
                     return 1;
                 }
                 if (!leftHasNext)
                 {
                     return -1;
                 }
                 int comparison = Comparer<object>.Default.Compare(leftIterator.Current, rightIterator.Current);
                 if (comparison != 0)
                 {
                     return comparison;
                 }
             }
         }
     }
 }