introduce new constructor in Kd_tree

This commit is contained in:
Jane Tournois 2024-03-07 15:12:47 +01:00
parent 45ea4541af
commit 258b4d3c82
2 changed files with 17 additions and 2 deletions

View File

@ -99,14 +99,20 @@ Constructs an empty `k-d` tree.
Kd_tree(Splitter s=Splitter(),Traits t=Traits());
/*!
Constructs a `k-d` tree on the elements from the sequence
`[first, beyond)` using the splitting rule implemented by `s`.
The value type of the `InputIterator` must be `Point_d`.
*/
template <class InputIterator> Kd_tree(InputIterator first, InputIterator beyond, Splitter s=Splitter(),Traits t=Traits());
/*!
Constructs a `k-d` tree on the elements from the range `points`
using the splitting rule implemented by `s`.
The value type of elements in `PointRange` must be `Point_d`.
*/
template <class PointRange>
Kd_tree(const PointRange& points, Splitter s = Splitter(), const Traits t = Traits());
/*!
The constructor does not build the internal data structure, and it
is also not updated after calls to `insert()`.

View File

@ -287,6 +287,15 @@ public:
: traits_(traits), split(s), pts(first, beyond), built_(false)
{ }
template <class PointRange>
Kd_tree(const PointRange& points,
Splitter s = Splitter(), const SearchTraits traits = SearchTraits())
: traits_(traits),
split(s),
pts(std::begin(points), std::end(points)),
built_(false)
{ }
bool empty() const {
return pts.empty();
}