StephenCleary / Comparers

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

String comparers #23

Closed StephenCleary closed 3 years ago

StephenCleary commented 5 years ago

Have a NaturalStringComparer (and case-insensitive variant). Possibly also WithStandardNullHandling wrappers for StringComparer instances.

StephenCleary commented 5 years ago

Light-up usage of CompareTo and Equals for spans of chars to make natural string comparisons allocation-free on .NET Core 2.1+.

The only really tricky part is GetHashCode. I think this can be passed to the corresponding StringComparer with the full string...

StephenCleary commented 5 years ago

Also need to consider Utf8StringComparer.

StephenCleary commented 4 years ago

Splitting out NaturalStringComparer and Utf8StringComparer to their own issues.

This issue is now focused on StringComparer helpers.

StephenCleary commented 4 years ago

6.1.0 has new APIs:

FixedStringComparer is essentially StringComparer with properties for each type of string comparer (Ordinal, InvariantCultureIgnoreCase, etc) with implementations that do not throw when GetHashCode(null) is called.

IFullComparer<string>.ToStringComparer() wraps a string comparer into a StringComparer-derived type.