38 #ifndef FCL_INTERVAL_TREE_INL_H
39 #define FCL_INTERVAL_TREE_INL_H
50 class IntervalTree<double>;
60 nil->stored_interval =
nullptr;
66 root->stored_interval =
nullptr;
69 recursion_node_stack_size = 128;
71 recursion_node_stack_top = 1;
72 recursion_node_stack[0].start_node =
nullptr;
80 std::deque<IntervalTreeNode<S>*> nodes_to_free;
86 nodes_to_free.push_back(x->
left);
90 nodes_to_free.push_back(x->
right);
94 while( nodes_to_free.size() > 0)
96 x = nodes_to_free.back();
97 nodes_to_free.pop_back();
100 nodes_to_free.push_back(x->
left);
104 nodes_to_free.push_back(x->
right);
111 free(recursion_node_stack);
115 template <
typename S>
140 template <
typename S>
164 template <
typename S>
182 if((y == root) || (y->
key > z->
key))
189 template <
typename S>
200 template <
typename S>
260 root->left->red =
false;
265 template <
typename S>
270 if(nil != (y = x->
right))
272 while(y->
left != nil)
284 if(y == root)
return nil;
290 template <
typename S>
295 if(nil != (y = x->
left))
297 while(y->
right != nil)
306 if(y == root)
return nil;
315 template <
typename S>
320 recursivePrint(x->
left);
322 recursivePrint(x->
right);
327 template <
typename S>
330 recursivePrint(root->left);
334 template <
typename S>
340 while((!x->
red) && (root_left_node != x))
409 template <
typename S>
418 template <
typename S>
427 if(left != nil)
return left;
429 if(right != nil)
return right;
436 template <
typename S>
443 y= ((z->
left == nil) || (z->
right == nil)) ? z : getSuccessor(z);
488 if(!(y->
red)) deleteFixup(x);
492 return node_to_delete;
497 template <
typename S>
511 template <
typename S>
514 std::deque<SimpleInterval<S>*> result_stack;
516 bool run = (x != nil);
525 recursion_node_stack[current_parent].try_right_branch =
true;
529 if(recursion_node_stack_top == recursion_node_stack_size)
531 recursion_node_stack_size *= 2;
533 if(recursion_node_stack ==
nullptr)
536 recursion_node_stack[recursion_node_stack_top].start_node = x;
537 recursion_node_stack[recursion_node_stack_top].try_right_branch =
false;
538 recursion_node_stack[recursion_node_stack_top].parent_index = current_parent;
539 current_parent = recursion_node_stack_top++;
546 while((!run) && (recursion_node_stack_top > 1))
548 if(recursion_node_stack[--recursion_node_stack_top].try_right_branch)
550 x=recursion_node_stack[recursion_node_stack_top].start_node->
right;
551 current_parent=recursion_node_stack[recursion_node_stack_top].parent_index;
552 recursion_node_stack[current_parent].try_right_branch =
true;