1 #ifndef _LINUX_RBTREE_H
2 #define _LINUX_RBTREE_H
6 struct rb_node *rb_left; /* left element */
7 struct rb_node *rb_right; /* right element */
8 struct rb_node *rb_parent; /* parent element */
9 int rb_color; /* node color */
13 struct rb_node *rb_node; /* root of the tree */
15 #define NULL ((void *)0)
16 #define RB_ROOT ((struct rb_root){NULL})
17 #define rb_entry(p, container, field) \
18 ((container *) ((char *)p - ((char *)&(((container *)0)->field))))
24 extern void rb_insert_color(struct rb_node *, struct rb_root *);
25 extern void rb_erase(struct rb_node *, struct rb_root *);
27 /* Find logical next and previous nodes in a tree */
28 extern struct rb_node *rb_next(struct rb_node *);
29 extern struct rb_node *rb_prev(struct rb_node *);
30 extern struct rb_node *rb_first(struct rb_root *);
32 /* Fast replacement of a single node without remove/rebalance/add/rebalance */
33 extern void rb_replace_node(struct rb_node *victim, struct rb_node *new,
34 struct rb_root *root);
36 static inline void rb_link_node(struct rb_node * node, struct rb_node * parent,
37 struct rb_node ** rb_link)
39 node->rb_parent = parent;
40 node->rb_color = RB_RED;
41 node->rb_left = node->rb_right = NULL;
46 #endif /* _LINUX_RBTREE_H */