For Programmers: Free Programming Magazines  


Home > Archive > Java Help > August 2007 > Re: How can i implements a class like an HashMap but with 2 keys









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: How can i implements a class like an HashMap but with 2 keys
Hendrik Maryns

2007-08-28, 7:17 pm

Jan Thomä schreef:
> Rob wrote:
>
> 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...


Have a look at Jakarta Commons Collections, it has MultiKey and
MultiKeyMap, which works exactly as you describe.

If you want a generic version, let me know.

H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html


Hendrik Maryns

2007-08-29, 8:11 am

Rob schreef:
> Hendrik Maryns wrote:
>
>
> Yes, i read in the api and seems perfect for what i have to do.
>
> A generic version is better, do you know where can i get it?


The Jakarta team has been very reluctant in starting a generic version.
Finally, there has been some advancement there. However, I have made
my own generic version, if you send me an e-mail, I can send it to you.

Mention which classes you would like.

Alternatively, there is ‘larvalabs’.

H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com