/** Sandbox to check functionality. Remember to remove this main */ public static void main(String args[]) { Pair<Integer> a = new Pair<Integer>(Label.temp, 100); Pair<Integer> b = new Pair<Integer>(Label.temp, 120); System.out.println("" + a.equals(b)); System.out.println(a); a.update(120); System.out.println("" + a.equals(b)); System.out.println(a); }
public static Pair bruteForce(List<? extends Point> points) { int numPoints = points.size(); if (numPoints < 2) return null; Pair pair = new Pair(points.get(0), points.get(1)); if (numPoints > 2) { for (int i = 0; i < numPoints - 1; i++) { Point point1 = points.get(i); for (int j = i + 1; j < numPoints; j++) { Point point2 = points.get(j); double distance = distance(point1, point2); if (distance < pair.distance) pair.update(point1, point2, distance); } } } return pair; }