this returns n (the location in the CellTree) if it is a leaf or 0 if the point doesn't contain in the data domain
| 233 | // this returns n (the location in the CellTree) if it is a leaf or 0 if the point doesn't |
| 234 | // contain in the data domain |
| 235 | const CellTreeNode<T>* Next() |
| 236 | { |
| 237 | while (true) |
| 238 | { |
| 239 | if (this->StackPtr == this->Stack) // This means the point is not within the domain |
| 240 | { |
| 241 | return nullptr; |
| 242 | } |
| 243 | |
| 244 | const TCellTreeNode* n = &this->Tree.Nodes.front() + *(--this->StackPtr); |
| 245 | |
| 246 | if (n->IsLeaf()) |
| 247 | { |
| 248 | return n; |
| 249 | } |
| 250 | |
| 251 | const double p = this->Pos[n->GetDimension()]; |
| 252 | const T left = n->GetLeftChildIndex(); |
| 253 | |
| 254 | bool l = p <= n->GetLeftMaxValue(); // Check if the points is within the left subtree |
| 255 | bool r = p >= n->GetRightMinValue(); // Check if the point is within the right subtree |
| 256 | |
| 257 | // This means if there is an overlap region both left and right subtrees should |
| 258 | // be traversed |
| 259 | if (l && r) |
| 260 | { |
| 261 | if (n->GetLeftMaxValue() - p < p - n->GetRightMinValue()) |
| 262 | { |
| 263 | *(this->StackPtr++) = left; |
| 264 | *(this->StackPtr++) = left + 1; |
| 265 | } |
| 266 | else |
| 267 | { |
| 268 | *(this->StackPtr++) = left + 1; |
| 269 | *(this->StackPtr++) = left; |
| 270 | } |
| 271 | } |
| 272 | else if (l) |
| 273 | { |
| 274 | *(this->StackPtr++) = left; |
| 275 | } |
| 276 | else if (r) |
| 277 | { |
| 278 | *(this->StackPtr++) = left + 1; |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | }; |
| 283 | |
| 284 | //------------------------------------------------------------------------------ |
no test coverage detected