Igor Sysoev | f5003d8 | 2003-12-04 14:53:00 +0000 | [diff] [blame] | 1 | #ifndef _NGX_RBTREE_H_INCLUDED_ |
| 2 | #define _NGX_RBTREE_H_INCLUDED_ |
| 3 | |
| 4 | |
| 5 | #include <ngx_config.h> |
| 6 | #include <ngx_core.h> |
| 7 | |
| 8 | |
| 9 | typedef struct ngx_rbtree_s ngx_rbtree_t; |
| 10 | |
| 11 | struct ngx_rbtree_s { |
| 12 | ngx_int_t key; |
| 13 | ngx_rbtree_t *left; |
| 14 | ngx_rbtree_t *right; |
| 15 | ngx_rbtree_t *parent; |
Igor Sysoev | faca119 | 2003-12-05 07:11:46 +0000 | [diff] [blame] | 16 | char color; |
Igor Sysoev | f5003d8 | 2003-12-04 14:53:00 +0000 | [diff] [blame] | 17 | }; |
| 18 | |
Igor Sysoev | 62260f2 | 2003-12-05 17:07:27 +0000 | [diff] [blame^] | 19 | |
| 20 | void ngx_rbtree_insert(ngx_rbtree_t **root, ngx_rbtree_t *sentinel, |
| 21 | ngx_rbtree_t *node); |
| 22 | void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *sentinel, |
| 23 | ngx_rbtree_t *node); |
Igor Sysoev | f5003d8 | 2003-12-04 14:53:00 +0000 | [diff] [blame] | 24 | |
| 25 | |
Igor Sysoev | 62260f2 | 2003-12-05 17:07:27 +0000 | [diff] [blame^] | 26 | ngx_inline static ngx_rbtree_t *ngx_rbtree_min(ngx_rbtree_t *root, |
| 27 | ngx_rbtree_t *sentinel) |
Igor Sysoev | f5003d8 | 2003-12-04 14:53:00 +0000 | [diff] [blame] | 28 | { |
Igor Sysoev | 62260f2 | 2003-12-05 17:07:27 +0000 | [diff] [blame^] | 29 | while (root->left != sentinel) { |
Igor Sysoev | f5003d8 | 2003-12-04 14:53:00 +0000 | [diff] [blame] | 30 | root = root->left; |
| 31 | } |
| 32 | |
| 33 | return root; |
| 34 | } |
| 35 | |
| 36 | |
| 37 | #endif /* _NGX_RBTREE_H_INCLUDED_ */ |