#1
  1. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,635
    Rep Power
    1945

    How do I map values in serveral arrays


    Hi all

    I need some suggestion on this topic.

    The problem is that I have several arrays of which data is related to each other.

    For simplicity, I will "translate" it to the car maker, car model and year idea.
    When you select car maker you get a list of models and when you select model you get a list of model years.
    Just that in my case there can be overlapping; one model can be used by several makers.

    I have tried to search on the net, but all places I found assumed there was connection to a database.

    I have thought about following designs:

    1. one array with all the makers, one with all models and one with all the years
    Pros: data is only listed once
    Cons: Not sure how to make the mapping (could a 3d array be useful in this case!?)

    2. one array for each markers.
    Pros: You can select the list directly when the user has selected the maker
    Cons: As there is overlapping means there will be duplicated data
    Cons: If i have to to the same with the model-years, the code will be more complex with a lot of arrays.

    FYI, I use a program specific scripting language (mix between JavaScript and Java).

    Any suggestion will be nice.

    [EDIT]
    What I am trying now:
    have a separate list for each "maker" which contains index reference to the "models" array.
    something like this:
    Code:
    makers[0] = "Test model";
    
    model[0] = "Model 1";
    model[1] = "model 2";
    model[2] = "model 3";
    
    mapping["Test model"] = [0,1];
    
    ViewModelList = mapping[makers[0]]
    // on working....
    Will there be any flaw with the above?
    Last edited by MrFujin; November 22nd, 2010 at 07:23 AM.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2011
    Location
    Southampton,PA,USA
    Posts
    4
    Rep Power
    0

    How do I map values in serveral arrays


    You should use three array list, input data to them with same key of car and retrieve them on the basis of key from all of three.
  4. #3
  5. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,635
    Rep Power
    1945
    Thanks for the reply, have all forgotten i had this question open

    But it end up I were looking at the wrong part, the program I use have another way to solve the problem

IMN logo majestic logo threadwatch logo seochat tools logo