Skip to content

LambdaComparer class and extension methods additional to System.Linq.Enumerable methods

License

Notifications You must be signed in to change notification settings

vilinski/LambdaComparer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LambdaComparer

Build status

LambdaComparer class is a flexible IComparer<T> implementation, which compares the values returned from the specified selector.

var equalityComparer = new LambdaComparer<string,int>(x=>x.Length);
var dict = new Dictionary<string, string>(new LambdaComparer<string, int>(x => x.Length));
// can contain just one string of each length

There are also some extension methods additionall to System.Linq.Enumerable methods, using this comparer.

var list = new[] { "a", "aa", "aaa", "b", "bb", "bbb" };
var distinct = list.Distinct(x => x.Length); // returns { "a", "aa", "aaa" }
var list1 = new[] { "a", "aa", "aaa", "aaaa" };
var list2 = new[] { "dd", "eeee" };
var except = list1.Except(list2, x => x.Length); // returns { "a", "aaa" }
var list1 = new[] { "a", "aa", "aaa", "aaaa" };
var list2 = new[] { "dd", "eeee" };
var intersect = list1.Intersect(list2, x => x.Length); // returns { "aa", "aaaa" }

Build

Build the project using latest dotnet CLI (Currently 2.1.300)

dotnet build
dotnet test LambdaComparer.Test/
dotnet pack
dotnet nuget push -k mySecretNugetKey LambdaComparer.0.2.0.nupkg  -s "https://api.nuget.org/v3/index.json"

About

LambdaComparer class and extension methods additional to System.Linq.Enumerable methods

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages