前端:
FilterData(a, b) { //循环判断数组a里的元素在b里面有没有,有的话就放入新建立的数组中 //a有 b没有 var result = new Array(); var c = b.toString(); for (var i = 0; i < a.length; i++) { if (c.indexOf(a[i].toString()) == -1) { result.push(a[i]); } } return result; }
后端:后端通过Ip来判断数组对象元素
private List<Map<String, String>> getOffline(List<Map<String, String>> list, List<Map<String, String>> mapList) { int cf = 0; for (int i = 0; i < mapList.size(); i++) { for (int j = 0; j < list.size(); j++) { if (mapList.get(i).get("ip").equals(list.get(j).get("ip"))) { cf++; break; } } } boolean flag = false; List<Map<String, String>> mapList2 = new ArrayList<>(mapList.size() - cf); int xb = 0; for (int i = 0; i < mapList.size(); i++) { for (int j = 0; j < list.size(); j++) { if (mapList.get(i).get("ip").equals(list.get(j).get("ip"))) { flag = false; break; } else { flag = true; } } if (flag) { mapList2.add(xb, mapList.get(i)); xb++; } } return mapList2; }
标签:前后,get,++,元素,list,mapList,int,数组,size From: https://www.cnblogs.com/dabu/p/17012101.html