@Test public void testSpeed() { System.out.println("speed"); long start = System.currentTimeMillis(); List<Neighbor<String, String>> neighbors = new ArrayList<>(); for (int i = 1000; i < 1100; i++) { bktree.range(words[i], 1, neighbors); neighbors.clear(); } double time = (System.currentTimeMillis() - start) / 1000.0; System.out.format("BK-tree range 1 search: %.2fs%n", time); start = System.currentTimeMillis(); for (int i = 1000; i < 1100; i++) { bktree.range(words[i], 2, neighbors); neighbors.clear(); } time = (System.currentTimeMillis() - start) / 1000.0; System.out.format("BK-tree range 2 search: %.2fs%n", time); start = System.currentTimeMillis(); for (int i = 1000; i < 1100; i++) { bktree.range(words[i], 3, neighbors); neighbors.clear(); } time = (System.currentTimeMillis() - start) / 1000.0; System.out.format("BK-tree range 3 search: %.2fs%n", time); start = System.currentTimeMillis(); for (int i = 1000; i < 1100; i++) { bktree.range(words[i], 4, neighbors); neighbors.clear(); } time = (System.currentTimeMillis() - start) / 1000.0; System.out.format("BK-tree range 4 search: %.2fs%n", time); }
@Override public void range(E q, double radius, List<Neighbor<E, E>> neighbors) { if (radius <= 0 || radius != (int) radius) { throw new IllegalArgumentException("The parameter radius has to be an integer: " + radius); } search(root, q, (int) radius, neighbors); }
BKTree implements RNNSearch<E, E>, Serializable { @Override public void range(E q, double radius, List<Neighbor<E, E>> neighbors) { if (radius <= 0 || radius != (int) radius) { throw new IllegalArgumentException("The parameter radius has to be an integer: " + radius); } search(root, q, (int) radius, neighbors); } }
BKTree implements RNNSearch<E, E>, Serializable { @Override public void range(E q, double radius, List<Neighbor<E, E>> neighbors) { if (radius <= 0 || radius != (int) radius) { throw new IllegalArgumentException("The parameter radius has to be an integer: " + radius); } search(root, q, (int) radius, neighbors); } BKTree(Metric<E> distance); }
BKTree implements RNNSearch<E, E>, Serializable { @Override public void range(E q, double radius, List<Neighbor<E, E>> neighbors) { if (radius <= 0 || radius != (int) radius) { throw new IllegalArgumentException("The parameter radius has to be an integer: " + radius); } search(root, q, (int) radius, neighbors); } BKTree(Metric<E> distance); void add(E[] data); void add(Collection<E> data); @Override String toString(); void add(E datum); @Override void range(E q, double radius, List<Neighbor<E, E>> neighbors); void range(E q, int radius, List<Neighbor<E, E>> neighbors); }
BKTree implements RNNSearch<E, E>, Serializable { @Override public void range(E q, double radius, List<Neighbor<E, E>> neighbors) { if (radius <= 0 || radius != (int) radius) { throw new IllegalArgumentException("The parameter radius has to be an integer: " + radius); } search(root, q, (int) radius, neighbors); } BKTree(Metric<E> distance); void add(E[] data); void add(Collection<E> data); @Override String toString(); void add(E datum); @Override void range(E q, double radius, List<Neighbor<E, E>> neighbors); void range(E q, int radius, List<Neighbor<E, E>> neighbors);  }