views:

83

answers:

1

I would like to be able to retrieve from my com.google.collections.Multimap<A, B> a Collection<Entry<A, Collection<B>>> which I expected from the entries() method, but in fact it returns a Collection<Entry<A, B>>. Is there a method which does what I want?

Currently I'm iterating like this:

for (A key: mmap.keySet()) {
    Collection<B> = mmap.get(A);
    //do stuff
}

and I'd prefer to be able to iterate like this:

for (Entry<A, Collection<B>> entry: mmap.entries()) {
    //do stuff 
}
+11  A: 

You can use asMap() method:

for (Entry<A, Collection<B>> entry: mmap.asMap().entrySet()) {
    //do stuff 
}
True Soft