Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Class limitations?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00975772
Message ID:
00976020
Vues:
13
Einar,

A multimap (or one-to-many map) allows you to access multiple values to one key. This can be implemented as a Hashtable for key access with a custom indexer that returns another data structure, for example, an ArrayList. This allows you to express you data structure like this instead of having hundreds of properties.
MultiMap tempMap = new MultiMap();

tempMap.Add("1", "one");
tempMap.Add("2", "two");
tempMap.Add("3", "three");
tempMap.Add("3", "duplicate three");

Console.WriteLine(myMap["3"][0]);
Console.WriteLine(myMap["3"][1]);
As you can see we have added two entries to the "3" key of our Hashtable. We can also use a foreach loop to enumerate the contents.
foreach (DictionaryEntry mapentry in tempMap)
{
    Console.Write(mapentry.Key.ToString());

    foreach (object arrayentry in tempMap[mapentry.Key])
    {
        Console.Write(arrayentry.ToString());
    }
}
Or something like that, the real advantage to using a data structure like this is that you can optimize your algorithms to suite you object graph/application profile. The multimap approach may not fit your requirments but a data structure would be a better approach to 700+ properties (IMHO).

I can email the source to a multimap implementation if you would like it?

Regards
Neil
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform