List<VitalityMiddlePotentialSpace> highVitalitySpaceList = potentialSpaceMapper.getGt90PotentialSpace(); //获取高活力空间周边,附近300米点 Set<VitalityMiddlePotentialSpace> highVitalityPeripheryList = new HashSet<>(); highVitalitySpaceList.forEach(highVitalitySpace -> { List<VitalityMiddlePotentialSpace> peripheryList = potentialSpaceMapper.getHighVitalityPeriphery(highVitalitySpace.getGid()); if (ObjectUtils.isEmpty(peripheryList)) { return; } highVitalityPeripheryList.addAll(peripheryList); }); 如何将highVitalityPeripheryList中含有highVitalitySpaceList中的数据删除
时间: 2024-02-03 09:04:05 浏览: 53
滑动删除Listview中的数据
可以使用迭代器遍历 highVitalityPeripheryList,判断其中的元素是否在 highVitalitySpaceList 中,如果存在则使用迭代器的 remove() 方法将其删除。具体代码如下:
```
Iterator<VitalityMiddlePotentialSpace> iterator = highVitalityPeripheryList.iterator();
while (iterator.hasNext()) {
VitalityMiddlePotentialSpace peripherySpace = iterator.next();
for (VitalityMiddlePotentialSpace highVitalitySpace : highVitalitySpaceList) {
if (peripherySpace.getGid().equals(highVitalitySpace.getGid())) {
iterator.remove();
break;
}
}
}
```
阅读全文