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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:02:10+00:00 2026-05-11T05:02:10+00:00

I have an in-memory table that might looks something like this: Favorite# Name Profession

  • 0

I have an in-memory ‘table’ that might looks something like this:

Favorite#  Name        Profession ---------  ----------  ------------------ 3          Names.Adam  Profession.Baker 9          Names.Bob   Profession.Teacher 7          Names.Carl  Profession.Coder 7          Names.Dave  Profession.Miner 5          Names.Fred  Profession.Teacher 

And what I want to do, is do quick and efficient lookups, using any of the 3 fields. In other words, I want:

  • myTable[3] and myTable[Names.Adam] and myTable[Professions.Baker] to all return {3,Names.Adam,Profession.Baker}
  • myTable[Profession.Teacher] to return both {9,Names.Bob,Profession.Teacher} and {5,Names.Fred,Profession.Teacher}.

The table is built during runtime, according to the actions of the user, and cannot be stored in a database since it is used in sections in which database connectivity cannot be guaranteed.

Right now, I ‘simply’ (hah!) store this using 3 uber-Dictionaries, each keyed using one of the columns (FavoriteNumber, Name, Profession), and each value in the uber-Dictionaries holding 2 Dictionaries which are themselves keyed with each of the remaining columns (so the values in the ‘Name’ uber-dictionary are of the type Dictionary<FavoriteNumber,Profession[]> and Dictionary<Profession, FavoriteNumber[]>

This requires 2 lookups in 2 Dictionaries, and another traverse of an array (which usually holds 1 or 2 elements.)

Can anyone suggest a better way to do this? I don’t mind spending extra memory, since the table is likely to be small (no more than 20 entries) but I’m willing to sacrifice a little CPU to make it more readily maintainable code…

  • 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. 2026-05-11T05:02:10+00:00Added an answer on May 11, 2026 at 5:02 am

    Not really however using a dictionary, but if you create a collection of classes like this

    class Person {     public int FavoriteNumber;     public string Name;     public string Profession; } 

    you can use LINQ to search the collections.

    IList<Person> people = /* my collection */; var selectedPeople = people.Where(p => p.FavoriteNumber = 3); var selectedPeople2 = people.Where(p => p.Name == 'Bob'); var selectedPeople3 = people.Where(p => p.Profession = 'Teacher'); 

    or if you prefer the normal LINQ syntax

    var selectedPeople4 = from p in people                       where p.Name == 'Bob'                       select p; 

    Each of these selectedPeople variables will be typed as IEnumerable<Person> and you can use a loop to search through them.

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

Sidebar

Related Questions

We have a large MyISAM table that is used to archive old data. This
I have a database with a table that contains Name and CompanyName . They
I have some PL/SQL code that I think might have a memory leak. Everytime
I am trying to load an image in memory but might have memory issues
Ignoring unsafe code, .NET cannot have memory leaks. I've read this endlessly from many
I have a memory buffer corresponding to my screen resolution (1280x800 at 24-bits-per-pixel) that
I have a memory block that is divided into a series of location that
I have vague memory of a screenshot of a VS plugin that colors different
Suppose I have a table with a column name varchar(20) , and I store
I have user subscriptions in my DB, and the SUBSCRIPTIONS table has UID (that

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.