-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define Hashable Interface #49
Comments
Note: if two entry have same hash is doesn't mean they are equals. it just mean they are may be equals so we ask isEquals. |
If it only uses In cases where Does that make sense? |
You made a good reason. yes, i understand your point. But here my solution if we want accept primitive value and common object. We can fallback it if the key is primitive type, or wrap it on our default Hashable implementation. For other object we can do the same approach, wrap them on Hashable implementation that only equals if it compared with themself. |
For map implementation, expecially HashMap it advantage for us to define Hashable interface, this interface only require 2 method: hashCode and isEquals modeled after Java. The advantage having this interface are the HashMap no longer take hashfunction argument and move the responsibily of compare two key is equal to the interface. It maybe overkill what do you think?
The text was updated successfully, but these errors were encountered: