StephenCleary / Comparers

The last comparison library you'll ever need!
MIT License
427 stars 33 forks source link

Add unordered collection comparer #36

Closed StephenCleary closed 3 years ago

StephenCleary commented 3 years ago

Implements #35

The final equality algorithm calculates the equivalence class cardinality of both sequences simultaneously, treating one sequence as an "adder" and the other as a "subtractor". This permits an early end if sequences are different lengths (and do not implement Count), and also minimizes garbage for sequences with equivalent items at the same offsets. It also maintains the O(N) runtime.

There is no possibility of overflow/underflow since collections are realistically bound by a positive int count, and negative ints have a greater range than positive ints.

codecov-io commented 3 years ago

Codecov Report

Merging #36 (cf909b8) into master (9953db7) will increase coverage by 0.55%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #36      +/-   ##
==========================================
+ Coverage   91.95%   92.50%   +0.55%     
==========================================
  Files          45       47       +2     
  Lines         609      654      +45     
==========================================
+ Hits          560      605      +45     
  Misses         49       49              
Impacted Files Coverage Δ
.../Nito.Comparers.Core/EqualityComparerExtensions.cs 100.00% <100.00%> (ø)
...omparers.Core/Internals/CommutativeHashCombiner.cs 100.00% <100.00%> (ø)
src/Nito.Comparers.Core/Util/SequenceComparer.cs 100.00% <100.00%> (ø)
...to.Comparers.Core/Util/SequenceEqualityComparer.cs 100.00% <100.00%> (ø)
...ers.Core/Util/UnorderedSequenceEqualityComparer.cs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9953db7...cf909b8. Read the comment docs.