Skip to content

Commit 459af21

Browse files
committed
add default constructor and fill method
1 parent f839a01 commit 459af21

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

include/kdbush.hpp

+13
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <cstdint>
66
#include <tuple>
77
#include <vector>
8+
#include <cassert>
89

910
namespace kdbush {
1011

@@ -26,6 +27,9 @@ class KDBush {
2627

2728
static const std::uint8_t defaultNodeSize = 64;
2829

30+
KDBush(const std::uint8_t nodeSize_ = defaultNodeSize) : nodeSize(nodeSize_) {
31+
}
32+
2933
KDBush(const std::vector<TPoint> &points_, const std::uint8_t nodeSize_ = defaultNodeSize)
3034
: KDBush(std::begin(points_), std::end(points_), nodeSize_) {
3135
}
@@ -35,7 +39,16 @@ class KDBush {
3539
const TPointIter &points_end,
3640
const std::uint8_t nodeSize_ = defaultNodeSize)
3741
: nodeSize(nodeSize_) {
42+
fill(points_begin, points_end);
43+
}
3844

45+
void fill(const std::vector<TPoint> &points_) {
46+
fill(std::begin(points_), std::end(points_));
47+
}
48+
49+
template <typename TPointIter>
50+
void fill(const TPointIter &points_begin, const TPointIter &points_end) {
51+
assert(points.empty());
3952
const TIndex size = std::distance(points_begin, points_end);
4053

4154
points.reserve(size);

0 commit comments

Comments
 (0)