diff options
author | Abyss777 <abyss@fox5.ru> | 2017-03-20 15:54:13 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-03-20 15:54:13 +0500 |
commit | 696ac56a6174a5ebfec939871a579ba54ee96963 (patch) | |
tree | 127e9eb00d120c9dd48b49cb7ffbd8fd45e88ae5 | |
parent | 1455ad6ce058f02d812e23fb275265f105272f4d (diff) | |
download | trackermap-server-696ac56a6174a5ebfec939871a579ba54ee96963.tar.gz trackermap-server-696ac56a6174a5ebfec939871a579ba54ee96963.tar.bz2 trackermap-server-696ac56a6174a5ebfec939871a579ba54ee96963.zip |
Use Iterator for maps cleanup
-rw-r--r-- | src/org/traccar/database/DeviceManager.java | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/org/traccar/database/DeviceManager.java b/src/org/traccar/database/DeviceManager.java index f70b9b1a2..ae5784b01 100644 --- a/src/org/traccar/database/DeviceManager.java +++ b/src/org/traccar/database/DeviceManager.java @@ -19,6 +19,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -133,19 +134,19 @@ public class DeviceManager implements IdentityManager { device.setStatus(Device.STATUS_OFFLINE); } } - for (Long cachedDeviceId : devicesById.keySet()) { - if (!databaseDevicesIds.contains(cachedDeviceId)) { - devicesById.remove(cachedDeviceId); + for (Iterator<Long> iterator = devicesById.keySet().iterator(); iterator.hasNext();) { + if (!databaseDevicesIds.contains(iterator.next())) { + iterator.remove(); } } - for (String cachedDeviceUniqueId : devicesByUniqueId.keySet()) { - if (!databaseDevicesUniqueIds.contains(cachedDeviceUniqueId)) { - devicesByUniqueId.remove(cachedDeviceUniqueId); + for (Iterator<String> iterator = devicesByUniqueId.keySet().iterator(); iterator.hasNext();) { + if (!databaseDevicesUniqueIds.contains(iterator.next())) { + iterator.remove(); } } - for (String cachedDevicePhone : devicesByPhone.keySet()) { - if (!databaseDevicesPhones.contains(cachedDevicePhone)) { - devicesByPhone.remove(cachedDevicePhone); + for (Iterator<String> iterator = devicesByPhone.keySet().iterator(); iterator.hasNext();) { + if (!databaseDevicesPhones.contains(iterator.next())) { + iterator.remove(); } } } |