void inOrder(node *root){ if(NULL==root) return; root=getLeftMost(root); while(root){ if(root->threaded) printf("%d(1) ",root->data); else printf("%d(0) ",root->data); if(root->threaded) root=root->right; else root=getLeftMost(root->right); } }
void GLWidget::rangeSearch(TwoDTree::Node *p, RangeQuery &rq, std::vector<QPointF> &includingPoints) { if (p != nullptr) { double l; double r; double coord; if (p->isVertical) { l = qMin(rq.p2.y(), rq.p1.y()); r = qMax(rq.p2.y(), rq.p1.y()); coord = p->value.y(); } else { l = qMin(rq.p2.x(), rq.p1.x()); r = qMax(rq.p2.x(), rq.p1.x()); coord = p->value.x(); } if (p->value.y() <= getHighest(rq) && p->value.y() >= getLowest(rq) && p->value.x() >= getLeftMost(rq) && p->value.x() <= getRightMost(rq)) { includingPoints.push_back(p->value); } if (l < coord) { rangeSearch(p->left, rq, includingPoints); } if (r > coord) { rangeSearch(p->right, rq, includingPoints); } } }