Skip to content

UnderNotic/FastDictionaryComparer

Repository files navigation

logo

appveyor status NuGet

Compare dictionaries in performant way, much faster than using linq.

Installing

Simple use example

var set = Enumerable.Range(0, 10).Select(i => new Dictionary<string, string> { { "key1", i.ToString() }, { "key2", i.ToString() } });

var toFind = new Dictionary<string, string> { { "key1", "1" } };

var factory = new EquatableDictionaryFactory<string, string>(set.Concat(new[] { toFind1, toFind2, toFind3, toFind4 }).ToArray());

Assert.Contains(factory.CreateEquatableOneOfDictionary(toFind1), set.Select(factory.CreateEquatableOneOfDictionary)); // It's true

Api

public EquatableDictionaryFactory(Dictionary<T, Y>[] dicts, IEqualityComparer<T> keyEqualityComparer = null, IEqualityComparer<Y> valueEqualityComparer = null);

// EquatableDictionaryFactory methods
public EquatableDictionaryOneOf<T, Y> CreateEquatableOneOfDictionary(Dictionary<T, Y> dict);
public EquatableDictionaryAllOf<T, Y> CreateEquatableAllOfDictionary(Dictionary<T, Y> dict);

EquatableDictionaryOneOf

One of key-value pairs should match to consider two dictionaries being equal.

EquatableDictionaryAllOf

All of key-value pairs should match to consider two dictionaries being equal.

Benchmark

benchmark

See FastDictionaryComparer.Benchmark/Program.cs

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

Compare dictionaries in performant way, much faster than using linq.

Resources

License

Stars

Watchers

Forks

Languages