28 #ifndef __MDDS_QUAD_NODE_HPP__ 29 #define __MDDS_QUAD_NODE_HPP__ 31 #include "mdds/global.hpp" 35 #include <boost/intrusive_ptr.hpp> 39 #ifdef MDDS_DEBUG_NODE_BASE 40 size_t node_instance_count = 0;
41 inline size_t get_node_instance_count()
43 return node_instance_count;
68 enum search_region_space_t
98 inline node_quadrant_t opposite(node_quadrant_t quad)
103 return quad_southwest;
105 return quad_southeast;
107 return quad_northwest;
109 return quad_northeast;
110 case quad_unspecified:
114 return quad_unspecified;
117 template<
typename _NodePtr,
typename _NodeType,
typename _Key>
120 typedef _Key key_type;
121 typedef _NodePtr node_ptr;
122 typedef _NodeType node_type;
145 #ifdef MDDS_DEBUG_NODE_BASE 146 ++node_instance_count;
164 #ifdef MDDS_DEBUG_NODE_BASE 165 ++node_instance_count;
171 return !northeast && !northwest && !southeast && !southwest;
176 return x == r.x && y == r.y;
195 #ifdef MDDS_DEBUG_NODE_BASE 196 --node_instance_count;
198 static_cast<node_type*
>(
this)->dispose();
211 return other_y < y ? quad_northwest : quad_southwest;
214 return other_y < y ? quad_northeast : quad_southeast;
217 bool has_quadrant_node(node_quadrant_t quad)
const 222 return northeast.get() !=
nullptr;
224 return northwest.get() !=
nullptr;
226 return southeast.get() !=
nullptr;
228 return southwest.get() !=
nullptr;
235 node_ptr get_quadrant_node(node_quadrant_t quad)
const 259 template<
typename _NodePtr,
typename _NodeType,
typename _Key>
265 template<
typename _NodePtr,
typename _NodeType,
typename _Key>
273 template<
typename _NodePtr>
274 void disconnect_node_from_parent(_NodePtr p)
276 if (!p || !p->parent)
280 _NodePtr& parent = p->parent;
281 if (parent->northeast && parent->northeast == p)
283 parent->northeast.reset();
285 else if (parent->northwest && parent->northwest == p)
287 parent->northwest.reset();
289 else if (parent->southwest && parent->southwest == p)
291 parent->southwest.reset();
293 else if (parent->southeast && parent->southeast == p)
295 parent->southeast.reset();
298 throw general_error(
"parent node doesn't lead to the deleted node.");
301 template<
typename _NodePtr>
302 void disconnect_all_nodes(_NodePtr p)
309 disconnect_all_nodes(p->northeast);
310 p->northeast.reset();
315 disconnect_all_nodes(p->northwest);
316 p->northwest.reset();
321 disconnect_all_nodes(p->southeast);
322 p->southeast.reset();
327 disconnect_all_nodes(p->southwest);
328 p->southwest.reset();
334 template<
typename _NodeType,
typename _Key>
335 search_region_space_t get_search_region_space(
336 _NodeType* p, _Key x1, _Key y1, _Key x2, _Key y2)
338 typedef _Key key_type;
340 key_type x = p->x, y = p->y;
346 return region_northwest;
348 else if (y1 <= y && y <= y2)
354 return region_southwest;
356 else if (x1 <= x && x <= x2)
363 else if (y1 <= y && y <= y2)
365 return region_center;
376 return region_northeast;
378 else if (y1 <= y && y <= y2)
384 return region_southeast;
quad_node_base(const quad_node_base &r)
Definition: quad_node.hpp:154
Definition: global.hpp:58
Definition: flat_segment_tree.hpp:46
quad_node_base & operator=(const quad_node_base &r)
Definition: quad_node.hpp:182
node_quadrant_t get_quadrant(key_type other_x, key_type other_y) const
Definition: quad_node.hpp:207
Definition: quad_node.hpp:118