Re: How can i implements a class like an HashMap but with 2 keys ?
- From: Lew <lew@xxxxxxxxxxxxx>
- Date: Tue, 28 Aug 2007 08:36:34 -0400
Rob wrote:
i [sic] 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 [sic]
That's "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?
This would be the canonical solution. Make Pair immutable and generic if your keys are of general type, non-generic if you know what the key types are.
--
Lew
.
- References:
- Prev by Date: Re: 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: Re: 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
|