Skip to content

Commit

Permalink
mark search methods as const
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Jul 9, 2018
1 parent f74e923 commit bbbbf60
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions include/kdbush.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ class KDBush {
const TNumber minY,
const TNumber maxX,
const TNumber maxY,
const TVisitor &visitor) {
const TVisitor &visitor) const {
range(minX, minY, maxX, maxY, visitor, 0, static_cast<TIndex>(ids.size() - 1), 0);
}

template <typename TVisitor>
void within(const TNumber qx, const TNumber qy, const TNumber r, const TVisitor &visitor) {
void within(const TNumber qx, const TNumber qy, const TNumber r, const TVisitor &visitor) const {
within(qx, qy, r, visitor, 0, static_cast<TIndex>(ids.size() - 1), 0);
}

Expand All @@ -84,7 +84,7 @@ class KDBush {
std::vector<std::pair<TNumber, TNumber>> points;

private:
std::uint8_t nodeSize;
const std::uint8_t nodeSize;

template <typename TVisitor>
void range(const TNumber minX,
Expand All @@ -94,7 +94,7 @@ class KDBush {
const TVisitor &visitor,
const TIndex left,
const TIndex right,
const std::uint8_t axis) {
const std::uint8_t axis) const {

if (points.empty()) return;

Expand Down Expand Up @@ -127,7 +127,7 @@ class KDBush {
const TVisitor &visitor,
const TIndex left,
const TIndex right,
const std::uint8_t axis) {
const std::uint8_t axis) const {

if (points.empty()) return;

Expand Down Expand Up @@ -210,7 +210,7 @@ class KDBush {
std::iter_swap(points.begin() + static_cast<std::int32_t>(i), points.begin() + static_cast<std::int32_t>(j));
}

TNumber sqDist(const TNumber ax, const TNumber ay, const TNumber bx, const TNumber by) {
TNumber sqDist(const TNumber ax, const TNumber ay, const TNumber bx, const TNumber by) const {
auto dx = ax - bx;
auto dy = ay - by;
return dx * dx + dy * dy;
Expand Down

0 comments on commit bbbbf60

Please sign in to comment.