aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/rbtree.h
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-06-17 11:11:15 -0700
committerDamjan Marion <dmarion@me.com>2019-06-18 13:55:59 +0000
commitbadf38a2b7559a313fda01811f86a9c25f4c00db (patch)
tree037f9b9c63a9ef38a5103b3ffbd100ae04082ac9 /src/vppinfra/rbtree.h
parentc87b66c86201458c0475d50c6e93f1497f9eec2e (diff)
vppinfra: rbtree custom insert/search/del
Type: feature Add support for insert/search/del with custom compare function. Change-Id: Ibb740afc224d8adc29d3e1b51b46cdd738d1bd93 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vppinfra/rbtree.h')
-rw-r--r--src/vppinfra/rbtree.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/vppinfra/rbtree.h b/src/vppinfra/rbtree.h
index 79437cdd719..65580584b6d 100644
--- a/src/vppinfra/rbtree.h
+++ b/src/vppinfra/rbtree.h
@@ -45,15 +45,22 @@ typedef struct rb_tree_
rb_node_index_t root; /**< root index */
} rb_tree_t;
+typedef int (*rb_tree_lt_fn) (u32 a, u32 b);
+
void rb_tree_init (rb_tree_t * rt);
rb_node_index_t rb_tree_add (rb_tree_t * rt, u32 key);
rb_node_index_t rb_tree_add2 (rb_tree_t * rt, u32 key, uword opaque);
+rb_node_index_t rb_tree_add_custom (rb_tree_t * rt, u32 key, uword opaque,
+ rb_tree_lt_fn ltfn);
void rb_tree_del (rb_tree_t * rt, u32 key);
+void rb_tree_del_custom (rb_tree_t * rt, u32 key, rb_tree_lt_fn ltfn);
void rb_tree_free_nodes (rb_tree_t * rt);
u32 rb_tree_n_nodes (rb_tree_t * rt);
rb_node_t *rb_tree_min_subtree (rb_tree_t * rt, rb_node_t * x);
rb_node_t *rb_tree_max_subtree (rb_tree_t * rt, rb_node_t * x);
rb_node_t *rb_tree_search_subtree (rb_tree_t * rt, rb_node_t * x, u32 key);
+rb_node_t *rb_tree_search_subtree_custom (rb_tree_t * rt, rb_node_t * x,
+ u32 key, rb_tree_lt_fn ltfn);
rb_node_t *rb_tree_successor (rb_tree_t * rt, rb_node_t * x);
rb_node_t *rb_tree_predecessor (rb_tree_t * rt, rb_node_t * x);