Go to the documentation of this file.
38 #ifndef HPP_FCL_INTERVAL_TREE_INL_H
39 #define HPP_FCL_INTERVAL_TREE_INL_H
55 -(std::numeric_limits<FCL_REAL>::max)();
61 (std::numeric_limits<FCL_REAL>::max)();
76 std::deque<IntervalTreeNode*> nodes_to_free;
80 nodes_to_free.push_back(
x->left);
82 if (
x->right !=
nil) {
83 nodes_to_free.push_back(
x->right);
87 while (nodes_to_free.size() > 0) {
88 x = nodes_to_free.back();
89 nodes_to_free.pop_back();
91 nodes_to_free.push_back(
x->left);
93 if (
x->right !=
nil) {
94 nodes_to_free.push_back(
x->right);
111 if (
y->left !=
nil)
y->left->parent =
x;
113 y->parent =
x->parent;
115 if (
x ==
x->parent->left)
118 x->parent->right =
y;
124 std::max(
x->left->max_high, std::max(
x->right->max_high,
x->high));
125 y->max_high = std::max(
x->max_high, std::max(
y->right->max_high,
y->high));
135 if (
nil !=
x->right)
x->right->parent =
y;
137 x->parent =
y->parent;
138 if (
y ==
y->parent->left)
141 y->parent->right =
x;
147 std::max(
y->left->max_high, std::max(
y->right->max_high,
y->high));
148 x->max_high = std::max(
x->left->max_high, std::max(
y->max_high,
x->high));
177 std::max(
x->high, std::max(
x->left->max_high,
x->right->max_high));
193 while (
x->parent->red) {
195 if (
x->parent ==
x->parent->parent->left) {
196 y =
x->parent->parent->right;
198 x->parent->red =
true;
200 x->parent->parent->red =
true;
201 x =
x->parent->parent;
203 if (
x ==
x->parent->right) {
207 x->parent->red =
false;
208 x->parent->parent->red =
true;
212 y =
x->parent->parent->left;
214 x->parent->red =
false;
216 x->parent->parent->red =
true;
217 x =
x->parent->parent;
219 if (
x ==
x->parent->left) {
223 x->parent->red =
false;
224 x->parent->parent->red =
true;
237 if (
nil != (
y =
x->right)) {
238 while (
y->left !=
nil)
y =
y->left;
242 while (
x ==
y->right) {
255 if (
nil != (
y =
x->left)) {
256 while (
y->right !=
nil)
y =
y->right;
260 while (
x ==
y->left) {
286 while ((!
x->red) && (root_left_node !=
x)) {
287 if (
x ==
x->parent->left) {
288 w =
x->parent->right;
291 x->parent->red =
true;
293 w =
x->parent->right;
303 w =
x->parent->right;
305 w->
red =
x->parent->red;
306 x->parent->red =
false;
315 x->parent->red =
true;
329 w->
red =
x->parent->red;
330 x->parent->red =
false;
353 if (left !=
nil)
return left;
355 if (right !=
nil)
return right;
368 x = (
y->left ==
nil) ?
y->right :
y->left;
369 if (
root == (
x->parent =
y->parent)) {
372 if (
y ==
y->parent->left) {
375 y->parent->right =
x;
382 y->max_high = -(std::numeric_limits<FCL_REAL>::max)();
405 return node_to_delete;
420 std::deque<SimpleInterval*> result_stack;
427 if (
overlap(low, high,
x->key,
x->high)) {
428 result_stack.push_back(
x->stored_interval);
431 if (
x->left->max_high >= low) {
void recursivePrint(IntervalTreeNode *node) const
recursively print a subtree
std::deque< SimpleInterval * > query(FCL_REAL low, FCL_REAL high)
Return result for a given query.
Class describes the information needed when we take the right branch in searching for intervals but p...
void fixupMaxHigh(IntervalTreeNode *node)
Travels up to the root fixing the max_high fields after an insertion or deletion.
IntervalTreeNode * getSuccessor(IntervalTreeNode *node) const
Get the successor of a given node.
void recursiveInsert(IntervalTreeNode *node)
Inserts node into the tree as if it were a regular binary tree.
IntervalTreeNode * parent
void rightRotate(IntervalTreeNode *node)
right rotation of tree node
SimpleInterval * stored_interval
interval stored in the node
void print() const
Print the whole interval tree.
bool overlap(FCL_REAL a1, FCL_REAL a2, FCL_REAL b1, FCL_REAL b2)
returns 1 if the intervals overlap, and 0 otherwise
IntervalTreeNode * recursiveSearch(IntervalTreeNode *node, SimpleInterval *ivl) const
recursively find the node corresponding to the interval
The node for interval tree.
IntervalTreeNode * start_node
unsigned int current_parent
unsigned int recursion_node_stack_top
IntervalTreeNode * getPredecessor(IntervalTreeNode *node) const
get the predecessor of a given node
void leftRotate(IntervalTreeNode *node)
left rotation of tree node
bool red
red or black node: if red = false then the node is black
unsigned int recursion_node_stack_size
IntervalTreeNode * insert(SimpleInterval *new_interval)
Insert one node of the interval tree.
Interval trees implemented using red-black-trees as described in the book Introduction_To_Algorithms_...
void deleteFixup(IntervalTreeNode *node)
unsigned int parent_index
it_recursion_node * recursion_node_stack
SimpleInterval * deleteNode(IntervalTreeNode *node)
Delete one node of the interval tree.
hpp-fcl
Author(s):
autogenerated on Fri Aug 2 2024 02:45:14