Lines Matching refs:node

33 #define RB_EMPTY_NODE(node)  \
34 ((node)->__rb_parent_color == (unsigned long)(node))
35 #define RB_CLEAR_NODE(node) \
36 ((node)->__rb_parent_color = (unsigned long)(node))
53 /* Fast replacement of a single node without remove/rebalance/add/rebalance */
59 static inline void rb_link_node(struct rb_node *node, struct rb_node *parent,
62 node->__rb_parent_color = (unsigned long)parent;
63 node->rb_left = node->rb_right = NULL;
65 *rb_link = node;
68 static inline void rb_link_node_rcu(struct rb_node *node, struct rb_node *parent,
71 node->__rb_parent_color = (unsigned long)parent;
72 node->rb_left = node->rb_right = NULL;
74 rcu_assign_pointer(*rb_link, node);
108 static inline void rb_insert_color_cached(struct rb_node *node,
113 root->rb_leftmost = node;
114 rb_insert_color(node, &root->rb_root);
119 rb_erase_cached(struct rb_node *node, struct rb_root_cached *root)
123 if (root->rb_leftmost == node)
124 leftmost = root->rb_leftmost = rb_next(node);
126 rb_erase(node, &root->rb_root);
157 * rb_add_cached() - insert @node into the leftmost cached tree @tree
158 * @node: node to insert
159 * @tree: leftmost cached tree to insert @node into
160 * @less: operator defining the (partial) node order
162 * Returns @node when it is the new leftmost, or NULL.
165 rb_add_cached(struct rb_node *node, struct rb_root_cached *tree,
174 if (less(node, parent)) {
182 rb_link_node(node, parent, link);
183 rb_insert_color_cached(node, tree, leftmost);
185 return leftmost ? node : NULL;
189 * rb_add() - insert @node into @tree
190 * @node: node to insert
191 * @tree: tree to insert @node into
192 * @less: operator defining the (partial) node order
195 rb_add(struct rb_node *node, struct rb_root *tree,
203 if (less(node, parent))
209 rb_link_node(node, parent, link);
210 rb_insert_color(node, tree);
214 * rb_find_add() - find equivalent @node in @tree, or add @node
215 * @node: node to look-for / insert
217 * @cmp: operator defining the node order
219 * Returns the rb_node matching @node, or NULL when no match is found and @node
223 rb_find_add(struct rb_node *node, struct rb_root *tree,
232 c = cmp(node, parent);
242 rb_link_node(node, parent, link);
243 rb_insert_color(node, tree);
251 * @cmp: operator defining the node order
259 struct rb_node *node = tree->rb_node;
261 while (node) {
262 int c = cmp(key, node);
265 node = node->rb_left;
267 node = node->rb_right;
269 return node;
279 * @cmp: operator defining node order
281 * Returns the leftmost node matching @key, or NULL.
287 struct rb_node *node = tree->rb_node;
290 while (node) {
291 int c = cmp(key, node);
295 match = node;
296 node = node->rb_left;
298 node = node->rb_right;
309 * @cmp: operator defining node order
311 * Returns the next node matching @key, or NULL.
314 rb_next_match(const void *key, struct rb_node *node,
317 node = rb_next(node);
318 if (node && cmp(key, node))
319 node = NULL;
320 return node;
325 * @node: iterator
328 * @cmp: operator defining node order
330 #define rb_for_each(node, key, tree, cmp) \
331 for ((node) = rb_find_first((key), (tree), (cmp)); \
332 (node); (node) = rb_next_match((key), (node), (cmp)))