mirror of
https://github.com/nginx/nginx.git
synced 2024-12-18 21:23:36 -06:00
Core: introduced ngx_rbtree_next().
This commit is contained in:
parent
c1d8318d31
commit
0212c7fac1
@ -378,3 +378,32 @@ ngx_rbtree_right_rotate(ngx_rbtree_node_t **root, ngx_rbtree_node_t *sentinel,
|
||||
temp->right = node;
|
||||
node->parent = temp;
|
||||
}
|
||||
|
||||
|
||||
ngx_rbtree_node_t *
|
||||
ngx_rbtree_next(ngx_rbtree_t *tree, ngx_rbtree_node_t *node)
|
||||
{
|
||||
ngx_rbtree_node_t *root, *sentinel, *parent;
|
||||
|
||||
sentinel = tree->sentinel;
|
||||
|
||||
if (node->right != sentinel) {
|
||||
return ngx_rbtree_min(node->right, sentinel);
|
||||
}
|
||||
|
||||
root = tree->root;
|
||||
|
||||
for ( ;; ) {
|
||||
parent = node->parent;
|
||||
|
||||
if (node == root) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (node == parent->left) {
|
||||
return parent;
|
||||
}
|
||||
|
||||
node = parent;
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,8 @@ void ngx_rbtree_insert_value(ngx_rbtree_node_t *root, ngx_rbtree_node_t *node,
|
||||
ngx_rbtree_node_t *sentinel);
|
||||
void ngx_rbtree_insert_timer_value(ngx_rbtree_node_t *root,
|
||||
ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel);
|
||||
ngx_rbtree_node_t *ngx_rbtree_next(ngx_rbtree_t *tree,
|
||||
ngx_rbtree_node_t *node);
|
||||
|
||||
|
||||
#define ngx_rbt_red(node) ((node)->color = 1)
|
||||
|
Loading…
Reference in New Issue
Block a user