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

  • Home
  • SEARCH
  • 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 7443255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:18:10+00:00 2026-05-29T11:18:10+00:00

I have this object: Public Cactus{ Public Double key; Public String value; } I

  • 0

I have this object:

Public Cactus{
    Public Double key;
    Public String value;
}

I have about ~100 Cactus, which all have a unique key, and a value that has some duplicates.
I will however have to retrieve the value for a key about ~2000 times.
My Key values varies between -10 and 280.

I want this process to be as quick as possible. What would be the best approach for this? I was thinking using a HashTable, although I always used one with Integer and not Double, and for some reason I am worried that it’s not good practice to use Double as Key.

Given my scenario, which collection would be the best to use?

  • 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-29T11:18:11+00:00Added an answer on May 29, 2026 at 11:18 am

    Using a double as a key in a dictionary is generally a really bad idea. You will run into all sorts of problems with representation errors where you think you stored 0.1 in the dictionary but actually you stored something very close to but not quite equal to 0.1.

    I’d suggest using another type (string?) if you need exact matches.

    If you don’t want exact matches but just finding the closest value, consider something like a SortedList instead.

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

Sidebar

Related Questions

I have this object: class a { public string Application; public DateTime From, To;
I have this method in cs page: public String getToolTip(Object productId, Object imgBtnId) {
I have a JPA object which has a many-to-many relationship like this: @Entity public
I have this object Object1 defined as public Object1(String item, List<Object2> obj2) in a
I have this class/object below: public class Person { public string FirstName; public string
I have this ValueConverter: public class LabelConverter : IValueConverter { public object Convert(object value,
I have this object : public class Person { public string FirstName { get;
Assume I have this domain object... public class SpansMultipleTables { public int CommonID {get;
I have this interface: public interface IValidationCRUD { public ICRUDValidation IsValid(object obj); private void
I'm just wondering .. I have and object like this public class Entry{ public

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.