Skip to content

Commit

Permalink
Add a variant of find_point_closest_first with an implicit min_distance
Browse files Browse the repository at this point in the history
  • Loading branch information
CLIDragon committed Aug 29, 2024
1 parent 9e3bdf3 commit b039e74
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,10 @@ std::vector<point> closest_points_first( const point &center, int min_dist, int

return result;
}

template <typename PredicateFn, typename Point>
std::optional<Point> find_point_closest_first( const Point &center, int max_dist,
PredicateFn &&fn )
{
return find_point_closest_first( center, 0, max_dist, fn );
};
5 changes: 5 additions & 0 deletions src/point.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ template <typename PredicateFn, typename Point>
std::optional<Point> find_point_closest_first( const Point &center, int min_dist, int max_dist,
PredicateFn &&fn );

template <typename PredicateFn, typename Point>
std::optional<Point> find_point_closest_first( const Point &center, int max_dist,
PredicateFn &&fn );


// Calculate the number of tiles in a square from min_dist to max_dist about an arbitrary centre.
inline std::optional<int> rectangle_size( int min_dist, int max_dist )
{
Expand Down

0 comments on commit b039e74

Please sign in to comment.