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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:09:57+00:00 2026-06-12T02:09:57+00:00

I am having 3 datasets, say A B and C. A contains single array

  • 0

I am having 3 datasets, say A B and C.
A contains single array of 5 elements. B contains a 2D array and C also contains a 2D array.
A contains 5 elements which are independent of B and C.
for each element in A, an array is associated in B and for each element in that array of B, an array is associated in C.. so i want to store these data sets in a data structure so that selecting an element in A should give appropriate element array in B and selecting an element in that array of B should give an elements of C.. can anybody suggest me one..i am using java programming language to implement this data structure..

  • 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-12T02:09:58+00:00Added an answer on June 12, 2026 at 2:09 am

    If I understood you correctly, you are looking for a mapping from elements of A to elements of B, and from those to C. The easiest way to achieve this would be to use some HashMaps, or any other class implementing the Map interface, for example:

    List<TypeA> a = new ArrayList<TypeA>();
    Map<TypeA, List<TypeB>> b = new HashMap<TypeA, List<TypeB>>();
    Map<TypeB, List<TypeC>> c = new HashMap<TypeB, List<TypeC>>();
    

    This way, a is just your array A. b maps the elements from a to lists, which are the rows in your 2D array B. Similarly, c maps the elements from those rows to lists, which are the rows in C.

    Alternatively, you could use a single nested Map for all three:

    Map<TypeA, Map<TypeB, List<TypeC>>> abc = 
            new HashMap<TypeA, Map<TypeB, List<TypeC>>>;
    

    This way, the keys in abc correspond to your array A. The value to each key is again a map, whose keys are the elements of the row in B corresponding to that element from A. Finally, the values for each of those keys are the rows in C corresponding to those elements in B.

    Note that the keys in a Map are not ordered, so if order is important (for example if you have to iterate over A in any specific order, or if you have to access them by some index) you should go with the first solution. If order is important for b and c as well, you could try this:

    List<TypeA> a = new ArrayList<TypeA>();
    List<List<TypeB>> b = new ArrayList<List<TypeB>>();
    List<List<TypeC>> c = new ArrayList<List<TypeC>>();
    Map<TypeA, Integer> ab = new HashMap<TypeA, Integer>();
    Map<TypeB, Integer> bc = new HashMap<TypeB, Integer>();
    

    Here, a, b and c correspond directly to your A, B and C (if you know how many elements they will have you can use arrays, too). ab and bc then hold the mapping from each element of a (or b) to the corresponding indices in b (or c). Note that you will have to update ab and bc whenever you insert elements into a or b.

    Thus, if order is not important, I would recommend the second solution, since this way you do not have to ‘synchronize’ a, b and c.

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

Sidebar

Related Questions

The problem that i'm having is how can i synchronise my datasets in my
Let say i have one asp.net application that is having some page that uses
Having trouble with each function... Will try to explain by example... In my code,
I have few tables in the database with parent table say P is having
Say in the document classification domain, if I'm having a dataset of 1000 instances
I'm having such a problem: got dataset with a table(s). Say, we have already
Hi all I am having trouble with the sorting of my gridview. Let's say
I'm having some trouble with Visual Studio and the creation of DataSets from a
We are having some issues with our data layer when large datasets are returned
So I have several large datasets that I need to make more readable and

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.