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 7092459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:18:58+00:00 2026-05-28T08:18:58+00:00

Is there a datastructure like a Dictionary that allows adding unique elements based on

  • 0

Is there a datastructure like a Dictionary that allows adding unique elements based on the .Equals() call defined for a given class rather than hash value.

In my case, I have a PointD class defining a point with decimal X and Y. Due to the nature of decimal types being a little inexact, creating a hash on the point is not possible, as a small error between two points that are essentially the same will cause major difference in hash value.

Basically, I want to be able to count the number of points of each x, y combination. Is there an existing mechanism for this, or do I need to implement this myself?

  • 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-28T08:18:58+00:00Added an answer on May 28, 2026 at 8:18 am

    Be careful. It sounds like you want to define Equals so that values within a certain tolerance are considered equal. If you do that, Equals will not be transitive, but it needs to be transitive for the dictionary to function.

    Example: suppose x is smaller than y by 0.8 times the tolerance. They would be considered equal. Now consider the value z, which is larger than y by 0.8 times the tolerance. Therefore y and z are also equal. But x and z are not equal!

    GetHashCode must return the same value for two equal objects. Since equality is not transitive in this system, you can prove that GetHashCode needs to return the same value for all objects, which causes your dictionary to act like a linked list (but with more storage overhead, that gets wasted).

    You could solve this by rounding all the points to a certain degree of precision, and calculating both the hash code and equality from the rounded value. That approach may have pitfalls of its own, of course.

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

Sidebar

Related Questions

Is there any data structure in C# that is like a dictionary but that
I need a dictionary-like data structure that stores information as follows: key [value 1]
I have code that has a Dictionary defined as: Dictionary<int, StringBuilder> invoiceDict = new
Does there exist a cheat sheet for data structure like TreeMap, SortedMap, HashSet etc
There is a conversion process that is needed when migrating Visual Studio 2005 web
Is TRIE the most recommended data structure while designing something like a dictionary for
I need to test my data structure (in java) which is like a dictionary
I have a datastructure like this: [ [('A', '1'), ('B', '2')], [('A', '1'), ('B',
I want to use a datastructure like this: building string (indexed) date TDate (indexed)
My data structure looks like this <datastructure> <field1>data</field1> <field2>data</field2> <field3>data</field3> <field4>data</field4> <field4>data</field4> <field4>data</field4> <field4>data</field4>

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.