Skip to content

Commit

Permalink
Swap FillForward/Backward filler function args
Browse files Browse the repository at this point in the history
It is more natural to supply the "current" item first.
  • Loading branch information
atifaziz committed Jan 30, 2017
1 parent ac5f9ff commit c813ef2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion MoreLinq.Test/FillBackwardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void FillBackwardWithFillSelector()

var result =
xs.Select(x => new { X = x, Y = x })
.FillBackward(e => e.X == 0, (nm, m) => new { m.X, nm.Y });
.FillBackward(e => e.X == 0, (m, nm) => new { m.X, nm.Y });

Assert.That(result, Is.EquivalentTo(new[]
{
Expand Down
4 changes: 2 additions & 2 deletions MoreLinq.Test/FillForwardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ select line.Trim() into line
Value = int.Parse(val),
});

data = data.FillForward(e => e.Continent == "-", (f, e) => new { f.Continent, e.Country, e.City, e.Value })
.FillForward(e => e.Country == "-", (f, e) => new { e.Continent, f.Country, e.City, e.Value });
data = data.FillForward(e => e.Continent == "-", (e, f) => new { f.Continent, e.Country, e.City, e.Value })
.FillForward(e => e.Country == "-", (e, f) => new { e.Continent, f.Country, e.City, e.Value });


Assert.That(data, Is.EquivalentTo(new[]
Expand Down
2 changes: 1 addition & 1 deletion MoreLinq/FillBackward.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static IEnumerable<T> FillBackwardImpl<T>(IEnumerable<T> source, Func<T, bool> p
foreach (var blank in blanks)
{
yield return fillSelector != null
? fillSelector(item, blank)
? fillSelector(blank, item)
: item;
}

Expand Down
2 changes: 1 addition & 1 deletion MoreLinq/FillForward.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static IEnumerable<T> FillForwardImpl<T>(IEnumerable<T> source, Func<T, bool> pr
{
yield return seeded
? fillSelector != null
? fillSelector(seed, item)
? fillSelector(item, seed)
: seed
: item;
}
Expand Down

0 comments on commit c813ef2

Please sign in to comment.