开发者

Why doesn't Google's Multimap's entries() method return Key/Collection pairs?

I would like to be able to retrieve from my com.google.collections.Multimap<A, B> a Collection<Entry<A, Collection<B&开发者_Go百科gt;>> 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 
}


You can use asMap() method:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜