【发布时间】:2011-07-04 07:02:09
【问题描述】:
如何从 HashMAP 中获取相同的值?
HashMap<HashMap<String, Float>, String> HM=new HashMap<HashMap<String,Float>, String>();
HashMap<String, Float> h;
h=new HashMap<String, Float>();
h.put("X", 48.0f);
h.put("Y", 80.0f);
HM.put(typeValuesHM, "Red");
h=new HashMap<String, Float>();
h.put("X", 192.0f);
h.put("Y", 80.0f);
HM.put(typeValuesHM, "Red");
h=new HashMap<String, Float>();
h.put("X", 192.0f);
h.put("Y", 320.0f);
HM.put(typeValuesHM, "Blue");
h=new HashMap<String, Float>();
h.put("X", 336.0f);
h.put("Y", 560.0f);
HM.put(typeValuesHM, "Blue");
我的HashMap HM的值如下:
{ {x=48,y=80}=Red,{x=192,y=80}=Red,{x=192,y=320}=Blue,{x=336,y=560}=Blue }
这里,
我想统计HashMap HM中的相似值。
ie) 如果我给出的值等于“红色”,则表示我想得到 count=2。 如果我给出的值等于“蓝色”,则意味着我想得到 count=2。
如何从 HashMAP HM 中获取相同的值?
【问题讨论】: