Menu

Point2D and Vector2D override equals but not HashCode

Help
2016-06-08
2016-06-08
  • Elliot Osborne

    Elliot Osborne - 2016-06-08

    Lovely library, but I ran into a problem because I was expecting Point2D and Vector2D hashcodes to depend only on the x and y values (ie, I expected new Vector2D(1,1).hashCode() == new Vector2D(1, 1).hashCode(), which isn't the case).

    Since it's customary to override .hashCode when you override .equals, could you implement hashCode on these classes?

     
  • David

    David - 2016-06-08

    sure, hashCode has to be implemented that way!
    I started writing the libray years aga, and was not yet aware of this. I will fix it.
    By the way, I have moved the repository to GitHub (and to the Git versioning system), making it more easy to manage: https://github.com/dlegland/javaGeom

    regards,
    David

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.