Codechange: Make kdtree member functions const for const-correctness (#13099)

This commit is contained in:
SamuXarick 2024-11-19 12:36:56 +00:00 committed by GitHub
parent d2496b6ec4
commit 60ae50e016
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -308,7 +308,7 @@ class Kdtree {
} }
/** Check if the entire tree is in need of rebuilding */ /** Check if the entire tree is in need of rebuilding */
bool IsUnbalanced() bool IsUnbalanced() const
{ {
size_t count = this->Count(); size_t count = this->Count();
if (count < 8) return false; if (count < 8) return false;
@ -316,7 +316,7 @@ class Kdtree {
} }
/** Verify that the invariant is true for a sub-tree, assert if not */ /** Verify that the invariant is true for a sub-tree, assert if not */
void CheckInvariant(size_t node_idx, int level, CoordT min_x, CoordT max_x, CoordT min_y, CoordT max_y) void CheckInvariant(size_t node_idx, int level, CoordT min_x, CoordT max_x, CoordT min_y, CoordT max_y) const
{ {
if (node_idx == INVALID_NODE) return; if (node_idx == INVALID_NODE) return;
@ -341,7 +341,7 @@ class Kdtree {
} }
/** Verify the invariant for the entire tree, does nothing unless KDTREE_DEBUG is defined */ /** Verify the invariant for the entire tree, does nothing unless KDTREE_DEBUG is defined */
void CheckInvariant() void CheckInvariant() const
{ {
#ifdef KDTREE_DEBUG #ifdef KDTREE_DEBUG
CheckInvariant(this->root, 0, std::numeric_limits<CoordT>::min(), std::numeric_limits<CoordT>::max(), std::numeric_limits<CoordT>::min(), std::numeric_limits<CoordT>::max()); CheckInvariant(this->root, 0, std::numeric_limits<CoordT>::min(), std::numeric_limits<CoordT>::max(), std::numeric_limits<CoordT>::min(), std::numeric_limits<CoordT>::max());