I need a java dictionary that would be like (C# representation):
Dictionary<SomeEnumType, List<int, long>>
So I want to use it like this:
List<int, long> v1 = myDic[SomeEnumType.Value1];
foreach(int i in v1)
{
long l1 = v1[i];
}
And the List should be unique based on the int value.
What java structure supports the above?
You would use something like this:
You would not want to use
Listbecause it stores single items whereas you want a collection of key-value pairs or mappings. AHashMapwill only store objects for unique keys. In this case, the innerHashMapwill store only unique integers and the outerHashMapwill store only unique Enum types. You can look at the different available implementations ofMapto see which one will best suit your needs.Reference: http://docs.oracle.com/javase/7/docs/api/java/util/Map.html