Exemplo n.º 1
0
            public bool NextBatch(T[] batch, out int count)
            {
                count = 0;
                while (source.NextBatch(sourceBatch, out int sbCount))
                {
                    int start = 0;
                    if (skip > 0)
                    {
                        int toSkip = Math.Min(skip, sbCount);
                        start += toSkip;
                        skip  -= toSkip;
                    }
                    for (int i = start; i < sbCount; i++)
                    {
                        batch[count] = sourceBatch[i];
                        count++;
                        if (count == batch.Length)
                        {
                            return(true);
                        }
                    }
                }

                return(count > 0);
            }
Exemplo n.º 2
0
            public bool NextBatch(TResult[] batch, out int count)
            {
                if (!source.NextBatch(sourceBatch, out count))
                {
                    return(false);
                }

                for (int i = 0; i < count; i++)
                {
                    batch[i] = selector(sourceBatch[i]);
                }
                return(true);
            }
Exemplo n.º 3
0
            public bool NextBatch(T[] batch, out int count)
            {
                count = 0;
                while (take > 0 && count < batch.Length && source.NextBatch(sourceBatch, out int sbCount))
                {
                    int toCopy = Math.Min(sbCount - count, take);
                    Array.Copy(sourceBatch, 0, batch, count, toCopy);
                    count += toCopy;
                    take  -= toCopy;
                }

                return(count > 0);
            }
Exemplo n.º 4
0
 public bool NextBatch(T[] batch, out int count)
 {
     count = 0;
     while (source.NextBatch(sourceBatch, out int sbCount))
     {
         for (int i = 0; i < sbCount; i++)
         {
             if (predicate(sourceBatch[i]))
             {
                 batch[count] = sourceBatch[i];
                 count++;
                 if (count == batch.Length)
                 {
                     return(true);
                 }
             }
         }
     }
     return(count > 0);
 }