Lines Matching refs:tree
49 struct rbtree *rb_search(struct rbtree *tree, uint64_t key) in rb_search() argument
53 while (tree) { in rb_search()
54 if (tree->key == key) in rb_search()
55 return tree; in rb_search()
56 else if (tree->key > key) in rb_search()
57 tree = tree->left; in rb_search()
59 best = tree; in rb_search()
60 tree = tree->right; in rb_search()
98 struct rbtree *rb_insert(struct rbtree *tree, struct rbtree *node) in rb_insert() argument
103 if (!tree) { in rb_insert()
108 if (is_red(tree->left) && is_red(tree->right)) in rb_insert()
109 color_flip(tree); in rb_insert()
111 if (node->key < tree->key) in rb_insert()
112 tree->left = rb_insert(tree->left, node); in rb_insert()
114 tree->right = rb_insert(tree->right, node); in rb_insert()
116 if (is_red(tree->right)) in rb_insert()
117 tree = rotate_left(tree); in rb_insert()
119 if (is_red(tree->left) && is_red(tree->left->left)) in rb_insert()
120 tree = rotate_right(tree); in rb_insert()
122 return tree; in rb_insert()
125 void rb_destroy(struct rbtree *tree) in rb_destroy() argument
127 if (tree->left) in rb_destroy()
128 rb_destroy(tree->left); in rb_destroy()
129 if (tree->right) in rb_destroy()
130 rb_destroy(tree->right); in rb_destroy()
131 free(tree); in rb_destroy()