Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6805435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:35:10+00:00 2026-05-26T19:35:10+00:00

I would like to implement some geometrical algorithms with numerical robustness. For this, a

  • 0

I would like to implement some geometrical algorithms with numerical robustness.

For this, a system-wide delta is used for geometric equality. equals() for points is implemented with a distance computation using the delta for approximate equality.

I would like to be able to use regular java Collections, e.g Set. But I can’t come up with a reasonable hashCode() implementation.

My guess is that an implementation for an efficient HashSet use would result in a space partitioning with “soft” borders. Points with distance less that delta to the partition border should be able to be classified in up to eight (for 3D) adjacent regions at the same time. Points close enough to be considered equal on behalf of their distance but lying on different sides of the partition would otherwise be “misclassified”.

This is what I can’t get my head around. hashCode() is like putting items in buckets with a single item ending up in a single bucket, while I would need to put it in up to eight.

What would be a resonable solution? Am I abusing the purpose of hashCode()? And what would be the most reasonable solution still using hashCode() 🙂

EDIT: Thank you, I had an intuition that there was something wrong with the idea but could not put my finger on it. You made the matter very clear

Please let me extend my question to : if I’m fine with slower HashSet operation (which is not a showstopper), I could have hashCode() return 1 as there is no correct implementation in my case, what dire consequences would there be (it terms of geometric computations), if I do implement equals() dropping the transitivity requirement?

EDIT I have found this post, highlighting the issues with missing transitivity and and this post, which is closely related to this one.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:35:11+00:00Added an answer on May 26, 2026 at 7:35 pm

    hashCode() can be equal for un-equals() objects. So, indeed, bucketing is probably just fine. For example, if you just use some hash function of the nearest “grid” point, where you can define that grid however you want, it will work as a hash function as long as you define the rounding consistently and correctly.

    However, you are not going to get a correct notion of equals() from your first definition. If A and B, and B and C, are within delta of one another, this does not mean that A and C are. Transitivity does not hold.

    You could define equals() in terms of bucketing. It may give slightly surprising results as points close but on the other side of a line are not equal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to implement some Drag-select functionality into a project of mine but
I would like to implement a command line interface for a Java application. This
I have Java servlet-based web applications. I would like to implement some operations in
I would like to implement some security in some of the Flash/PHP applications that
i would like to implement some kind of service my customers can use to
I would like to implement onfling (or some similar swipe) in listview in each
I would like to implement/embed a notes area where people can write some notes
I have some encrypted storage (SQLite) and would like to implement my own ContentProvider.
I'm using the core-plot library to do some plotting, and would like to implement
I try to implement some javascript functions for my Ipad device. I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.