Basically I want something like Dictionary
I would implement a data structure with these two dictionaries
Dictionary<TKey1, KeyValuePair<TKey2, TValue>> dict1;
Dictionary<TKey2, KeyValuePair<TKey1, TValue>> dict2;
That way if you are given 1 key you have both the value and the other key as well for easy deletes and updates.
Maybe an option:
Do as John Kugelman suggests, just add an item twice in the same dictionary. Then you keep a second dictionary that maps values to sets of keys.
When you add a key,value pair, you just add it as normal to the first dictionary and then retrieve the key set belonging to that value from the second dictionary and add the key.
Dictionary<TKey, TValue> dict1;
Dictionary<TValue, ICollection<TKey>> dict2;
Removing a value is done by retrieving the key set from dict2 and removing them one by one from dict1.
The number of keys is dict1.Count and the number of values is dict2.Count
What about a Multi Index Container inspired by boost??
Take a look at CodeProject.
I'm going to go out on a limb here and appear stupid, but you could just roll your own Dictionary based on two dictionaries. It wouldn't be too terribly difficult to write (even with locking mechanisms to ensure thread safety). I mean, there's plenty of examples out there where you can use an index or a key to access a collection. (Such as Session)
Conversely, if your multiple indexes are of the same type, you could just add the same item multiple times.
Dictionary will support something with a GUID index, as well as a simple name index "Joe" - you have to remember to add the item twice.
Two dictionaries, but don't duplicate the items in each.
You'll have a value dictionary, and a key dictionary.
When you call your add method, you'll generate a GUID and add it and the key to the keys dictionary.
Then, use the GUID as a key to the values dictionary.
If you want to add two keys, you'll add another item to the keys dictionary with the same GUID.
Of course this means every lookup requires two checks for the data, but never more, even if you have 50 keys for the same value.
Lookup the guid based on the key from the keys table, then lookup the data based on that guid in the values table.