@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SpatialTriple<?, ?> that = (SpatialTriple<?, ?>) o; if (position != null ? !position.equals(that.position) : that.position != null) return false; if (id != null ? !id.equals(that.id) : that.id != null) return false; return element != null ? element.equals(that.element) : that.element == null; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Impl other = (Impl) obj; if (bottomLeft == null) { if (other.bottomLeft != null) return false; } else if (!bottomLeft.equals(other.bottomLeft)) return false; if (height != other.height) return false; if (width != other.width) return false; return true; }
/** * Finds and returns the closest point containing a city to the given point. * Does not include provided point as a possible city location. * * If there are no cities, null is returned. * * @param point * @return */ public Coord closestCity(Coord point) { double dist = 999999999, newdist; Coord closest = null; for (Coord c : cities) { if (c.equals(point)) { continue;//skip the one being tested for } newdist = Math.pow(point.x - c.x, 2) + Math.pow(point.y - c.y, 2); if (newdist < dist) { dist = newdist; closest = c; } } return closest; }
Coord getCoord(HashSet<Coord> data, int x, int y) { Coord coord = new Coord(x, y); if (data.contains(coord)) { for (Coord c : data) { if (c.equals(coord)){ return c; } } } return null; }