blob: db435ff1c4859939847daaecd79f603df55f1366 [file] [log] [blame]
Igor Sysoevf5003d82003-12-04 14:53:00 +00001#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
9typedef struct ngx_rbtree_s ngx_rbtree_t;
10
11struct ngx_rbtree_s {
12 ngx_int_t key;
13 ngx_rbtree_t *left;
14 ngx_rbtree_t *right;
15 ngx_rbtree_t *parent;
Igor Sysoevfaca1192003-12-05 07:11:46 +000016 char color;
Igor Sysoevf5003d82003-12-04 14:53:00 +000017};
18
Igor Sysoev62260f22003-12-05 17:07:27 +000019
20void ngx_rbtree_insert(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
21 ngx_rbtree_t *node);
22void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
23 ngx_rbtree_t *node);
Igor Sysoevf5003d82003-12-04 14:53:00 +000024
25
Igor Sysoev62260f22003-12-05 17:07:27 +000026ngx_inline static ngx_rbtree_t *ngx_rbtree_min(ngx_rbtree_t *root,
27 ngx_rbtree_t *sentinel)
Igor Sysoevf5003d82003-12-04 14:53:00 +000028{
Igor Sysoev62260f22003-12-05 17:07:27 +000029 while (root->left != sentinel) {
Igor Sysoevf5003d82003-12-04 14:53:00 +000030 root = root->left;
31 }
32
33 return root;
34}
35
36
37#endif /* _NGX_RBTREE_H_INCLUDED_ */