PageRenderTime 20ms CodeModel.GetById 16ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Rhino.Etl.Tests/Fibonacci/FibonacciOperation.cs

http://github.com/ayende/rhino-etl
C# | 36 lines | 31 code | 5 blank | 0 comment | 1 complexity | 186519b689a1d8e7fee85be63ab8c3ab MD5 | raw file
 1using System.Collections.Generic;
 2using Rhino.Etl.Core;
 3using Rhino.Etl.Core.Operations;
 4
 5namespace Rhino.Etl.Tests.Fibonacci
 6{
 7    public class FibonacciOperation : AbstractOperation
 8    {
 9        private readonly int max;
10
11        public FibonacciOperation(int max)
12        {
13            this.max = max;
14        }
15
16        public override IEnumerable<Row> Execute(IEnumerable<Row> rows)
17        {
18            int a = 0;
19            int b = 1;
20            var row = new Row();
21            row["id"] = 1;
22            yield return row;
23
24            for (int i = 0; i < max - 1; i++)
25            {
26                int c = a + b;
27                row = new Row();
28                row["id"] = c;
29                yield return row;
30
31                a = b;
32                b = c;
33            }
34        }
35    }
36}