Re: How can i implements a class like an HashMap but with 2 keys ?



Rob wrote:
i want to create a class that works like an HashMap but
with 2 keys, get(key1,key2) -> value

I was thinking to create a class "Pair" that override equals and hashcode
and then store here the two keys and then a class that holds an HashMap
with Pair as key and the value class, can be this a solution?

Sounds good to me, actually you could just use a plain hashmap with that
pair class as key, no need to wrap it inside another class. What you could
also do is generating a string from the two keys which is then used as
combined key, but the pair thing looks cleaner to me...

Best regards,
Jan Thomä
--
_________________________________________________________________________
insOMnia - We never sleep...
http://www.insOMnia-hq.de

.



Relevant Pages

  • Re: Hashtable that doesnt store the key?
    ... > hashtable and I just want it to store the HashCode and the Value (two ... How will it distinguish 2 keys that have the same HashCode if you don't ... > Thanks - JackRazz ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Hashtable that doesnt store the key?
    ... > hashtable and I just want it to store the HashCode and the Value (two ... How will it distinguish 2 keys that have the same HashCode if you don't ... > Thanks - JackRazz ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How can i implements a class like an HashMap but with 2 keys ?
    ... and then store here the two keys and then a class that holds an HashMap ... actually you could just use a plain hashmap with that ... Have a look at Jakarta Commons Collections, it has MultiKey and ...
    (comp.lang.java.help)
  • Re: Buying Keys from Blizzard?
    ... Battlechest which has up to BC and another $40 for WotLK. ... point I can justify passing the store for the deal but if Blizz is ... DVD keys or buy the DVD keys from Blizzard. ...
    (alt.games.warcraft)
  • Re: EF Designer ignores my foreign key
    ... ItemGroupId}' that are partially contained in the set of primary keys ... I don't know why the EF team didn't fix this, and I can only describe from my own experience with reverse engineering an entity model from a relational schema, but as I do recall we had a similar bug very early on in LLBLGen Pro as well and I think it was even in the first beta cycle of v1. ... Well, unless they store that information, you can't: someone could have written the store XML meta data by hand and could have made an error. ...
    (microsoft.public.dotnet.framework.adonet)