multimap

Map implementation with duplicate keys

試著忘記壹切 提交于 2019-11-25 23:44:45
问题 I want to have a map with duplicate keys. I know there are many map implementations (Eclipse shows me about 50), so I bet there must be one that allows this. I know it\'s easy to write your own map that does this, but I would rather use some existing solution. Maybe something in commons-collections or google-collections? 回答1: You are searching for a multimap, and indeed both commons-collections and Guava have several implementations for that. Multimaps allow for multiple keys by maintaining a