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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:06:31+00:00 2026-05-10T22:06:31+00:00

When given a static set of objects (static in the sense that once loaded

  • 0

When given a static set of objects (static in the sense that once loaded it seldom if ever changes) into which repeated concurrent lookups are needed with optimal performance, which is better, a HashMap or an array with a binary search using some custom comparator?

Is the answer a function of object or struct type? Hash and/or Equal function performance? Hash uniqueness? List size? Hashset size/set size?

The size of the set that I’m looking at can be anywhere from 500k to 10m – incase that information is useful.

While I’m looking for a C# answer, I think the true mathematical answer lies not in the language, so I’m not including that tag. However, if there are C# specific things to be aware of, that information is desired.

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-10T22:06:32+00:00Added an answer on May 10, 2026 at 10:06 pm

    Ok, I’ll try to be short.

    C# short answer:

    Test the two different approaches.

    .NET gives you the tools to change your approach with a line of code. Otherwise use System.Collections.Generic.Dictionary and be sure to initialize it with a large number as initial capacity or you’ll pass the rest of your life inserting items due to the job GC has to do to collect old bucket arrays.

    Longer answer:

    An hashtable has ALMOST constant lookup times and getting to an item in an hash table in the real world does not just require to compute an hash.

    To get to an item, your hashtable will do something like this:

    • Get the hash of the key
    • Get the bucket number for that hash (usually the map function looks like this bucket = hash % bucketsCount)
    • Traverse the items chain (basically it’s a list of items that share the same bucket, most hashtables use this method of handling bucket/hash collisions) that starts at that bucket and compare each key with the one of the item you are trying to add/delete/update/check if contained.

    Lookup times depend on how ‘good’ (how sparse is the output) and fast is your hash function, the number of buckets you are using and how fast is the keys comparer, it’s not always the best solution.

    A better and deeper explanation: http://en.wikipedia.org/wiki/Hash_table

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

Sidebar

Related Questions

Given a group of objects that have a common set of properties and methods
Is it possible in MySQL to select from a static set of integers? Given
I was given an static library (.a extension file) that I have to use
Given this code snippet that can be readily pasted into Linqpad (or slightly modified
I've been given no other choice but to access a set of classes, which
Given below are two methods which create a delegate to set a field in
I'm interested in verifying if a given iPhone static library has been built for
How could I go about calling a method on a static class given the
Given public class Original { public static DoStuff() { } } public class Derived
Given this piece of code : public static void writeFile(File file,List buffer)throws IOException{ File

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.