You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Denis Avdic <de...@betterway.net> on 2003/05/29 21:25:17 UTC
[collections] HashMap with multiple values for one key
Hello,
I know this is probably a really stupid question but i am looking for a
HashMap (or similar)implementation that will store multiple objects
under the same key. I wrote a superficial implementation myself based
on the HashMap, but I am interested to know if there is something out
there already implementing this functionality. I really couldn't
decypher if multimap would do this.
Thanks,
Denis
Re: [collections] HashMap with multiple values for one key
Posted by Erik Price <ep...@ptc.com>.
Rob Leland wrote:
> Denis Avdic wrote:
>
>> Hello,
>>
>> I know this is probably a really stupid question but i am looking for
>> a HashMap (or similar)implementation that will store multiple objects
>> under the same key. I wrote a superficial implementation myself
>> based on the HashMap, but I am interested to know if there is
>> something out there already implementing this functionality. I really
>> couldn't decypher if multimap would do this.
>
>
> Why not just store an object which itself is a container.
>
> Either a class with public member functions, it could be a list, or even
> another Map ?
Possiblies
1. If you want to use an object that implements Map but don't want to
bother to implement all the stubs.
2. Item 30 of Effective Java: Know and Use Libraries
Erik
Re: [collections] HashMap with multiple values for one key
Posted by Denis Avdic <de...@betterway.net>.
Well, I want an option of taking out a key at a time with one function
call. (as in get). Being able to get the entire collection would be a
bonus.
I'll end up extending MultiHashMap so a get gets me the top of the stack
(or bucket, whatever you want to call it) and a getCol gets me the
entire contents of the key...
Rob Leland wrote:
> Denis Avdic wrote:
>
>> Hello,
>>
>> I know this is probably a really stupid question but i am looking for
>> a HashMap (or similar)implementation that will store multiple objects
>> under the same key. I wrote a superficial implementation myself
>> based on the HashMap, but I am interested to know if there is
>> something out there already implementing this functionality. I
>> really couldn't decypher if multimap would do this.
>
>
> Why not just store an object which itself is a container.
>
> Either a class with public member functions, it could be a list, or
> even another Map ?
>
>>
>>
>> Thanks,
>>
>> Denis
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
Re: [collections] HashMap with multiple values for one key
Posted by Rob Leland <rl...@apache.org>.
Denis Avdic wrote:
> Hello,
>
> I know this is probably a really stupid question but i am looking for
> a HashMap (or similar)implementation that will store multiple objects
> under the same key. I wrote a superficial implementation myself
> based on the HashMap, but I am interested to know if there is
> something out there already implementing this functionality. I really
> couldn't decypher if multimap would do this.
Why not just store an object which itself is a container.
Either a class with public member functions, it could be a list, or even
another Map ?
>
>
> Thanks,
>
> Denis