/** * Gets all the points neighboring the given point. These will be points * that are at most eps (radius) away from the given point. Uses the spatial * index (KD tree) if the metric is a Metric and points are Vectorizable. * Otherwise, performs a brute-force search. * * @param point The point to get the neighborhood for. * @return */ private List<DataType> regionQuery(DataType point) { List<DataType> result; if (this.metric instanceof Metric) { result = this.spatialIndex.findNearestWithinRadius( point, this.eps, (Metric<? super DataType>) this.metric) .stream() .map(pair -> pair.getFirst()) .collect(Collectors.toList()); } else { result = this.points.stream() .filter((p) -> (this.metric.evaluate(p, point) <= this.eps)) .collect(Collectors.toList()); } return result; }
/** * Gets all the points neighboring the given point. These will be points * that are at most eps (radius) away from the given point. Uses the spatial * index (KD tree) if the metric is a Metric and points are Vectorizable. * Otherwise, performs a brute-force search. * * @param point The point to get the neighborhood for. * @return */ private List<DataType> regionQuery(DataType point) { List<DataType> result; if (this.metric instanceof Metric) { result = this.spatialIndex.findNearestWithinRadius( point, this.eps, (Metric<? super DataType>) this.metric) .stream() .map(pair -> pair.getFirst()) .collect(Collectors.toList()); } else { result = this.points.stream() .filter((p) -> (this.metric.evaluate(p, point) <= this.eps)) .collect(Collectors.toList()); } return result; }
/** * Gets all the points neighboring the given point. These will be points * that are at most eps (radius) away from the given point. Uses the spatial * index (KD tree) if the metric is a Metric and points are Vectorizable. * Otherwise, performs a brute-force search. * * @param point The point to get the neighborhood for. * @return */ private List<DataType> regionQuery(DataType point) { List<DataType> result; if (this.metric instanceof Metric) { result = this.spatialIndex.findNearestWithinRadius( point, this.eps, (Metric<? super DataType>) this.metric) .stream() .map(pair -> pair.getFirst()) .collect(Collectors.toList()); } else { result = this.points.stream() .filter((p) -> (this.metric.evaluate(p, point) <= this.eps)) .collect(Collectors.toList()); } return result; }