[
https://issues.apache.org/jira/browse/LUCENENET-437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13067384#comment-13067384
]
Troy Howard commented on LUCENENET-437:
---------------------------------------
Well, it does, because of Object.hashCode()'s definition.
It ensures equality, but does not ensure inequality.
In other words, the contract ensures that for all types, this passes:
Assert.IsTrue(object1.equals(object2))
Assert.IsTrue(object1.hashCode().equals(object2.hashCode()))
but does not ensure that this passes:
Assert.IsFalse(object1.equals(object2))
Assert.IsFalse(object1.hashCode().equals(object2.hashCode()))
However, the docs state that while the equality of hashcodes may not be
consistent with inequality of hash codes, that all efforts should be made to
ensure both.
The problem we face is that with Hashtable/HashSet, we generally care more
about inequality (eg Uniqueness) than we do about equality (eg Sameness). What
we're trying to determine, using hashCode/equals is the uniqueness of an item
in the set, which is a different kind of logic (though clearly related).
So, using .hashCode() to determine uniqueness of an item in a set is incorrect,
it should always be correct for determining sameness.
> Port Contrib.Shingle from Java
> ------------------------------
>
> Key: LUCENENET-437
> URL: https://issues.apache.org/jira/browse/LUCENENET-437
> Project: Lucene.Net
> Issue Type: Task
> Components: Lucene.Net Contrib, Lucene.Net Test
> Affects Versions: Lucene.Net 2.9.4, Lucene.Net 2.9.4g
> Reporter: Troy Howard
> Assignee: Troy Howard
> Priority: Minor
> Fix For: Lucene.Net 2.9.4, Lucene.Net 2.9.4g
>
>
> Port Contrib.Shingle from Java
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira