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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:11:37+00:00 2026-05-26T04:11:37+00:00

Let’s say we have a big read only list of (int, string) elements. What

  • 0

Let’s say we have a big read only list of (int, string) elements.

What would be the fastest way to get an item from that list?

I know a generic dictionary is fast, but as far as I know it uses only 1 cpu, and today’s computers have at least 2 cpu’s.

As a side question: what would be the fastest solution to search this collection for multiple items? For example collection.GetItems(new int[]{1,2,3,4}), where 1,2,3,4 are the keys.

Thanks!

  • 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-26T04:11:38+00:00Added an answer on May 26, 2026 at 4:11 am

    A dictionary uses hash tables which should ammortize to O(1). Computing the hash on the keys should be very fast and the hash lookup is a direct array memory offset and hopefully walking a very short collision chain.

    Therefore I would not recommend optimizing the lookups unless a dictionary does not serve your needs and it’s too slow. You could argue that there’s a processor sitting there going to waste but trying to leverage that processor to optimize a problem that may not exist will complicate your code.

    I would recommend maintaining a lookup dictionary and for each lookups.

    The only consideration is memory. A dictionary will add a memory footprint to make the lookups fast – typical space vs. time.

    If you need to keep memory low and you need faster lookups and you have more processing power (multi-core), then maybe.

    In that case, I would recommend you look into the task parallel library. Here’s an article: http://www.codeproject.com/KB/cs/TPL1.aspx

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

Sidebar

Related Questions

Let's say I have a big file. The file is a list of IPs
Let's say we have a simple function defined in a pseudo language. List<Numbers> SortNumbers(List<Numbers>
Let's say that I have an arbitrary string like `A man + a plan
Let's say I have a class like this: public class Person { private String
let's say I have the following string: string s = A B C D
Let's say I have the following entity: public class Store { public List<Product> Products
Let's say I have a javascript array with a bunch of elements (anywhere from
Let's say I'm building a data access layer for an application. Typically I have
Let's say you have a class called Customer, which contains the following fields: UserName
Let's say I have a drive such as C:\ , and I want to

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.