nginx/src/core/ngx_rbtree.h

62 lines
1.3 KiB
C
Raw Normal View History

/*
* Copyright (C) Igor Sysoev
*/
2003-12-04 22:53:00 +08:00
#ifndef _NGX_RBTREE_H_INCLUDED_
#define _NGX_RBTREE_H_INCLUDED_
#include <ngx_config.h>
#include <ngx_core.h>
typedef ngx_uint_t ngx_rbtree_key_t;
typedef ngx_int_t ngx_rbtree_key_int_t;
typedef struct ngx_rbtree_node_s ngx_rbtree_node_t;
struct ngx_rbtree_node_s {
ngx_rbtree_key_t key;
ngx_rbtree_node_t *left;
ngx_rbtree_node_t *right;
ngx_rbtree_node_t *parent;
char color;
};
2003-12-04 22:53:00 +08:00
typedef struct ngx_rbtree_s ngx_rbtree_t;
2006-10-28 22:20:13 +08:00
typedef void (*ngx_rbtree_insert_pt) (ngx_rbtree_node_t *root,
ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel);
2003-12-04 22:53:00 +08:00
struct ngx_rbtree_s {
ngx_rbtree_node_t *root;
ngx_rbtree_node_t *sentinel;
2006-10-28 22:20:13 +08:00
ngx_rbtree_insert_pt insert;
2003-12-04 22:53:00 +08:00
};
void ngx_rbtree_insert(ngx_thread_volatile ngx_rbtree_t *tree,
ngx_rbtree_node_t *node);
void ngx_rbtree_delete(ngx_thread_volatile ngx_rbtree_t *tree,
ngx_rbtree_node_t *node);
2006-10-28 22:20:13 +08:00
void ngx_rbtree_insert_timer_value(ngx_rbtree_node_t *root,
ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel);
2003-12-04 22:53:00 +08:00
static ngx_inline ngx_rbtree_node_t *
ngx_rbtree_min(ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel)
2003-12-04 22:53:00 +08:00
{
while (node->left != sentinel) {
node = node->left;
}
2003-12-04 22:53:00 +08:00
return node;
2003-12-04 22:53:00 +08:00
}
#endif /* _NGX_RBTREE_H_INCLUDED_ */