Re: How can i implements a class like an HashMap but with 2 keys ?
- From: Jan Thomä <kork@xxxxxxxxxxxxxx>
- Date: Tue, 28 Aug 2007 14:28:30 +0200
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
.
- Follow-Ups:
- References:
- Prev by Date: How can i implements a class like an HashMap but with 2 keys ?
- Next by Date: Re: How can i implements a class like an HashMap but with 2 keys ?
- Previous by thread: How can i implements a class like an HashMap but with 2 keys ?
- Next by thread: Re: How can i implements a class like an HashMap but with 2 keys ?
- Index(es):
Relevant Pages
|