【发布时间】:2017-06-12 13:16:25
【问题描述】:
我有以下类型的地图:
private HashMap<Integer, HashMap<String, Object>> entireMap;
密钥从 1 到 n。整个地图中的子地图属于以下类型:
HashMap<String, Object> subMap = new HashMap<String, Object>();
整个地图的每个键都包含这个 subMap(以及更多):
subMap.put("user_name", usid[1]);
所以我最后有这样的东西:
{1 {"user_name" = "Arthur", "otherKeys = ..."}}
{2 {"user_name" = "Bela", "otherKeys = ..."}}
{3 {"user_name" = "Ceasar", "otherKeys = ..."}}
{4 {"user_name" = "Ceasar", "otherKeys = ..."}}
{5 {"user_name" = "Bela", "otherKeys = ..."}}
{6 {"user_name" = "Bela", "otherKeys = ..."}}
现在我想计算一个用户名在整个地图中的最大出现次数,在这种情况下它将是 3(bela 出现 3 次)。
我该怎么做?
【问题讨论】:
-
但是在 subMap 中,你不能有重复的键..
-
对不起,我刚刚注意到您的示例的每条记录都是@整个地图级别。