bool remove(const Bounds& area, const Bounds& b) { if (m_leaf) return area.contains(m_data.item); int cdel = 0; for (int i = 0; i < 4; ++i) { Node** c = m_data.children + i; if (!*c) continue; Bounds cb = b.quadrant(i); if (area.intersects(cb) && (*c)->remove(area, cb)) { delete *c; * c = 0; ++cdel; } } return cdel == 4; // true if all sub-nodes were removed }
void iterate(QuadTree::Iteration& iter, const Bounds& area, const Bounds& b) const { if (m_leaf && b.contains(m_data.item)) iter.process(m_data.item); else for (int i = 0; i < 4; ++i) { if (m_data.children[i]) { Bounds cb = b.quadrant(i); if (area.intersects(cb)) m_data.children[i]->iterate(iter, area, cb); } } }