Giter VIP home page Giter VIP logo

Comments (4)

diegofrata avatar diegofrata commented on June 11, 2024

It's a very good point! Perhaps I can actually check if both the enumerables implement IDictionary<TKey, TValue> and avoid the extra allocation. Cheers for pointing that out!

from generator.equals.

PatrikBak avatar PatrikBak commented on June 11, 2024

It's a very good point! Perhaps I can actually check if both the enumerables implement IDictionary<TKey, TValue> and avoid the extra allocation. Cheers for pointing that out!

@diegofrata

Agreed. You can also add

// If we have two collections with different counts, we can efficiently resolve their inequality
if (x is ICollection<T> xCollection && y is ICollection<T> yCollection && xCollection.Count != yCollection.Count)
    return false;

// If we a set, we can use its optimized SetEquals method
if (x is ISet<T> xSet) return xSet.SetEquals(y);
if (y is ISet<T> ySet) return ySet.SetEquals(x);

from generator.equals.

diegofrata avatar diegofrata commented on June 11, 2024

I implemented this and bumped the version to 1.0.0 since it's a breaking change and I think it's decent enough to be called 1.0!

Regarding the SetEquals, I did not use your suggestion as UnorderedEquality is not intended to have set semantics. That would require a new attribute, likely called SetEquality.

from generator.equals.

diegofrata avatar diegofrata commented on June 11, 2024

I actually went ahead and renamed the attributes to OrderedEquality and UnorderedEquality to make it more clear, ended up having to bump to 2.0.0 just to be consistent with SemVer.

from generator.equals.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.