The gethashcode method does not guarantee that the value is unique.

Source: Internet
Author: User

When I used the word segmentation module, I assigned hashcode to each word, but found that its value is not unique;
For example, the values of "public egress" and "Antique" are both 6237203.

Why is there such a problem? In fact, there is an explanation in msdn:

Remarks

GethashcodeThe behavior depends on its implementation, which may be changed from a public Language Runtime Library version to another version. The reason may be to improveGethashcodePerformance. If requiredGethashcodeThe behavior remains unchanged. Please use your own, sure not to change the implementation to rewriteGethashcode.

That's right, because he used different methods to optimize the speed.Algorithm, Resulting in the emergence of the same value, the solution is as he said, write a fixed algorithm.

If you have used this method before, you have to change it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.