先上数据结构,简化版思路:
public List<Map<String, Object>> trees(List<Map<String, Object>> trees){
List<Map<String, Object>> trees=new ArrayList<>();
Map map1=new HashMap();
map1.put("you","holle");
trees.add(map1);
Map map2=new HashMap();
map2.put("you","holle");
trees.add(map2);
Map map3=new HashMap();
map3.put("you","holle2");
trees.add(map3);
List<Map<String, Object>> mapList = newTrees(trees);
return mapList;
}
对于这种集合里面key是一样的,但是值不同的去重,有个简单的笨一点的方法。
public List<Map<String, Object>> newTrees(List<Map<String, Object>> trees){
List<Map<String, Object>> mapList=new ArrayList<>();
Map map=new HashMap();
for (Map<String, Object> t