- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
List<Address> addresses = loadFromDatabase();
Map<Integer, Address> sortMap = new HashMap<>();
for (Address address : addresses) {
if (address.getLatitude() != null && address.getLongitude() != null) {
sortMap.put(new Coords(address.getLatitude(), address.getLongitude()).hashCode(), address);
}
}
addresses = new ArrayList<>(sortMap.values());
...
class Coords {
...
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + latitude.hashCode();
result = prime * result + longitude.hashCode();
return result;
}
}
Комментарии (0) RSS
Добавить комментарий