日期:2014-05-20 浏览次数:20771 次
public class Test4 {
public static void main(String[] args) {
Map<String,Map<String,Set<String>>> oldmap=new HashMap<String, Map<String,Set<String>>>();
}
public Map<String,Map<String,Set<String>>> getothermap(Map<String,Map<String,Set<String>>> oldmap,Map<String,Map<String,Set<String>>> newmap){
Map<String,Map<String,Set<String>>> othermap=new HashMap<String, Map<String,Set<String>>>();
for(String cid:oldmap.keySet()){
Map<String,Set<String>> oldcidmap=oldmap.get(cid);
Map<String,Set<String>> newcidmap=newmap.get(cid);
Map<String,Set<String>> othercidmap=new HashMap<String, Set<String>>();
Set<String> oldcolorset=oldcidmap.get("color");
Set<String> oldsizeset=oldcidmap.get("size");
Set<String> newcolorset=newcidmap.get("color");
Set<String> newsizeset=newcidmap.get("size");
Set<String> othercolorset=new HashSet<String>();
Set<String> othersizeset=new HashSet<String>();
othercidmap.put("color", othercolorset);
othercidmap.put("size", othersizeset);
for(String attval:oldcolorset){
if(!newcolorset.contains(attval)){
othercolorset.add(attval);
}
}
for(String attval:oldsizeset){
if(!newsizeset.contains(attval)){
othersizeset.add(attval);
}
}
}
return othermap;
}
}
class Goods{
String id;
Set<String> colors;
Set<String> sizes;
//getter and setter
}