Hi,
I know that having duplicate keys in a map is not possible, but is there
anything in java that can do such a thing?
example;
key1
- "one"
- "1"
- "uno"
key2
- "two"
- "2"
- "ect"
so by using key2 I can access all the data (return an enumeration ect)
associated with key2.
thanks in advance
lee
Vova Reznik - 22 Feb 2006 20:36 GMT
> Hi,
>
[quoted text clipped - 23 lines]
> ------->>>>>>http://www.NewsDemon.com<<<<<<------
> Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
It is Map of Maps
key="key1", value - another map where keys are "one", "1", "uno",
"один", "ieden", ...
Andrew McDonagh - 22 Feb 2006 20:37 GMT
> Hi,
>
[quoted text clipped - 23 lines]
> ------->>>>>>http://www.NewsDemon.com<<<<<<------
> Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
sure... have a map of arrayList objects
Scott.R.Lemke@gmail.com - 22 Feb 2006 20:39 GMT
> Hi,
>
[quoted text clipped - 18 lines]
> thanks in advance
> lee
You could have a map where the value is a datastructure that holds an
indeterminate amount of values. Or you could (ab)use a hashmap in ways
no hashmap should be (ab)used.
Jeffrey Schwab - 22 Feb 2006 20:46 GMT
> I know that having duplicate keys in a map is not possible, but is there
> anything in java that can do such a thing?
http://java.sun.com/docs/books/tutorial/collections/interfaces/map.html
Scroll down to the section on Multimaps.
bugbear - 27 Feb 2006 11:21 GMT
>> I know that having duplicate keys in a map is not possible, but is
>> there anything in java that can do such a thing?
>
> http://java.sun.com/docs/books/tutorial/collections/interfaces/map.html
>
> Scroll down to the section on Multimaps.
They mention it,
jakarta common collections DOES it:
http://jakarta.apache.org/commons/collections/apidocs-COLLECTIONS_3_1/org/apache
/commons/collections/MultiMap.html
BugBear
tom fredriksen - 22 Feb 2006 22:10 GMT
> I know that having duplicate keys in a map is not possible, but is there
> anything in java that can do such a thing?
[quoted text clipped - 13 lines]
> so by using key2 I can access all the data (return an enumeration ect)
> associated with key2.
Just use an ArrayList as the value in the Hash, then you iterate the AL
when its returned.
/tom
Roedy Green - 24 Feb 2006 13:27 GMT
>I know that having duplicate keys in a map is not possible, but is there
>anything in java that can do such a thing?
sure a HashMap where the value is an array or ArrayList of the
duplicate values. When you discover the dup, you have to manage it
yourself by adding your element to the array/ArrayList/Collection
HashMap just hands you back the list of duplicates.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.