I'm using java objects like this:
public class GeoName {
private String country;
private String city;
private float lat;
private float lon;
}
I receive a List of GeoName and I would like to remove the duplicate cities in the same country that are in the list, as efficient as I could. I mean, if i receive the following list:
Madrid, Spain, ...
London, England, ...
Madrid, Mexico, ...
London, England, ...
Paris, France, ...
Madrid, Spain, ...
I would like to remove the repeated items (city+country) until the list was like this:
Madrid, Spain, ...
London, England, ...
Madrid, Mexico, ...
Paris, France, ...
I'm working on it but I don't know how to do it!
Any idea, please?
Thanks!
PS: I can't use a Set collection because I found the name of a city repeated in a country with different latitude and longitude (it's strange, but they exist). So it wouldn't be a complitely equal item on the Set