The Artima Developer Community
Sponsored Link

Programming in Scala Forum
hashCode

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Hjalmar Peters

Posts: 1
Nickname: 74782
Registered: Jan, 2011

hashCode Posted: Aug 25, 2012 12:18 PM
Reply to this message Reply
Advertisement
In Chapter 30 the hashCode examples are of this form:
override def hashCode = 41 * (41 + x) + y

This formula is equivalent to 41 * 41 + 41 * x + y. I wonder about the meaning of the constant offset 41 * 41. It seems that it just makes the hashCode values larger, the hashcode formula more complex and the calculation slower.

So, what is the advantage of the formula above compared to
override def hashCode = 41 * x + y

Topic: Functional Objects Chapter : Rational Numbers Previous Topic   Next Topic Topic: Scala-based Software Tools Critical for CX

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use