public List<INavigableVessel> getShipsInSegments(Point2D location, int radius) { int[] index = calculateIndices(location); final Point2D locationBefore = pointInterner.intern(getPointOnMap(location.getX() - radius, location.getY())); int[] indexBefore = calculateIndices(locationBefore); final Point2D locationAfter = pointInterner.intern(getPointOnMap(location.getX() + radius, location.getY())); int[] indexAfter = calculateIndices(locationAfter); Set<INavigableVessel> set = new HashSet<>(); if (indexBefore != index) { set.addAll(getShipsInSegment(locationBefore)); } set.addAll(getShipsInSegment(location)); if (indexAfter != index) { set.addAll(getShipsInSegment(locationAfter)); } return new ArrayList<>(set); }