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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:00:24+00:00 2026-06-16T03:00:24+00:00

I want to create a HashMap with RGB colors as keys. How should I

  • 0

I want to create a HashMap with RGB colors as keys. How should I store them to have best performance?
I mean, how does the “speed” of a hashmap refer to the object type of the key?

Should I use Integer (018052175) where each triplet would be one of RGB, String (1234AF) as HEX, or own Color class with int r, g, b? What might be the fastest implementation?

  • 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-06-16T03:00:25+00:00Added an answer on June 16, 2026 at 3:00 am

    The speed of hash map is constrained by several essential properties of the hashCode and equals functions:

    • How easy it is to calculate,
    • How well is hashCode at distributing values into buckets, and
    • How easy it is to compare values for equality

    The hashCode function of a String is very good, and String caches its result to improve performance. However, equality check may be longer than with Integer.

    The Integer class has a very hard-to-beat implementation of hashCode in terms of speed, but since the hash codes of similar colors would be close to each other, you may get more collisions with Integers.

    Color is as fast as the Integer, but it is also the most descriptive. I seriously doubt that choosing one of these three representations would hamper performance so significantly as to make a visible difference, so I would suggest going for the most descriptive choice, and then profile if necessary.

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

Sidebar

Related Questions

I want to create a HashMap<String, HashMap<String, Long>> I know in guava we have
I have data in a hashmap, and I want to create a histogram over
i want create image animation , i have 50 images with png format now
I have these classes that I use to create objects that I want to
I want to create a hashmap of classes like (Object.class). I am wondering whether
after I create a new object : Map<Float,Integer> m = new HashMap()<Float,Integer>; I have
I have a superclass called Canvas, from which I create several subclasses. I want
My vision is to create a color coded listView, where I want to have
I have a problem. I want to create a search engine which is based
I want to be able to create a fixed size hashmap of say 100

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.