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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:11:07+00:00 2026-06-09T15:11:07+00:00

I am looking to store my data in a data structure which allows me

  • 0

I am looking to store my data in a data structure which allows me to do the following efficiently:

I have 10 arrays of type 1 and 10 arrays of type 2 with 100 elements each. Each of these array store values of 100 variables. Accompanying these I have 20 arrays containing the corresponding variable IDs.
In total arrays of type 1 store values of 1000 variables and arrays of type 2 store different values of the same 1000 variables.

Now, I need to take a difference of the values of variables in arrays of type 1 from that of arrays of type 2. Let A be the one of the array of type 1. The problem is that variables in A would be spread 10 each across all 10 arrays of type 2.

A hash map would not be useful as I also need to iterate over the values in each array. Any ideas?

  • 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-09T15:11:09+00:00Added an answer on June 9, 2026 at 3:11 pm

    If you are intending to do such operations often you might want to construct and index at the program startup (the construction has O(n^2) time complexity) once and then refer to it later.

    struct LookupEntry {
       A *item1;
       B *item2;
    };
    
    std::map< IdType, LookupEntry > index;
    

    This would allow you to linearly go through arrays of type A and get the values from arrays of type B in a constant time. You can also subtract B items from A in a similar fashion.

    Alternatively, you can go through the index items and subtract one item from another.

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

Sidebar

Related Questions

I'm looking for an ordered data structure which allows very fast insertion. That's the
i am looking for a data structure to store two dimensional integer arrays. Is
I am looking for a good data-structure to store a simple key value mapping,
I'm looking for [free] server software to store hierarchal data efficiently. My key challenge
I was asked the following Question: How would you store the data given below(which
I have two tables which have the exact same structure. Both tables can store
Is there an R data structure into which I can store a number of
I'm looking for a data structure like com.google.common.collect.SortedSetMultimap which additionally implements the java.util.NavigableMap interface.
I'm looking for a simple solution using Python to store data as a flat
I am looking for an eventually consistent key value data store and i decided

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.