33#ifndef INNOBASE_UT0RBT_H
34#define INNOBASE_UT0RBT_H
36#if !defined(IB_RBT_TESTING)
45#define ut_malloc malloc
47#define ulint unsigned long
48#define ut_a(c) assert(c)
49#define ut_error assert(0)
101#define rbt_size(t) (t->n_nodes)
104#define rbt_empty(t) (rbt_size(t) == 0)
107#define rbt_value(t, n) ((t *)&n->value[0])
110#define rbt_compare(t, k, n) (t->compare(k, n->value))
187#if defined UNIV_DEBUG || defined IB_RBT_TESTING
required string key
Definition: replication_asynchronous_connection_failover.proto:60
static int compare(size_t a, size_t b)
Function to compare two size_t integers for their relative order.
Definition: rpl_utility.cc:107
The result of searching for a key in the tree, this is useful for a speedy lookup and insert if key d...
Definition: ut0rbt.h:92
int result
Definition: ut0rbt.h:95
const ib_rbt_node_t * last
Definition: ut0rbt.h:93
Red black tree node.
Definition: ut0rbt.h:61
char value[1]
Definition: ut0rbt.h:68
ib_rbt_node_t * left
Definition: ut0rbt.h:64
ib_rbt_node_t * parent
Definition: ut0rbt.h:66
ib_rbt_node_t * right
Definition: ut0rbt.h:65
ib_rbt_color_t color
Definition: ut0rbt.h:62
Red black tree instance.
Definition: ut0rbt.h:72
ulint sizeof_value
Definition: ut0rbt.h:86
void * cmp_arg
Definition: ut0rbt.h:87
ib_rbt_compare compare
Definition: ut0rbt.h:83
ib_rbt_node_t * root
Definition: ut0rbt.h:77
ib_rbt_arg_compare compare_with_arg
Definition: ut0rbt.h:84
ulint n_nodes
Definition: ut0rbt.h:81
ib_rbt_node_t * nil
Definition: ut0rbt.h:73
Version control for database, common definitions, and include files.
unsigned long int ulint
Definition: univ.i:406
void rbt_free(ib_rbt_t *tree)
Free an instance of a red black tree.
Definition: ut0rbt.cc:648
void(* ib_rbt_print_node)(const ib_rbt_node_t *node)
Definition: ut0rbt.h:53
ib_rbt_color_t
Red black tree color types.
Definition: ut0rbt.h:58
@ IB_RBT_BLACK
Definition: ut0rbt.h:58
@ IB_RBT_RED
Definition: ut0rbt.h:58
const ib_rbt_node_t * rbt_next(const ib_rbt_t *tree, const ib_rbt_node_t *current)
Return the next node from current.
Definition: ut0rbt.cc:940
int(* ib_rbt_arg_compare)(const void *, const void *p1, const void *p2)
Definition: ut0rbt.h:55
const ib_rbt_node_t * rbt_first(const ib_rbt_t *tree)
Return the left most data node in the tree.
Definition: ut0rbt.cc:908
ib_rbt_t * rbt_create(size_t sizeof_value, ib_rbt_compare compare)
Create an instance of a red black tree.
Definition: ut0rbt.cc:676
ib_rbt_node_t * rbt_remove_node(ib_rbt_t *tree, const ib_rbt_node_t *node)
Remove a node from the red black tree, NOTE: This function will not delete the node instance,...
Definition: ut0rbt.cc:818
const ib_rbt_node_t * rbt_last(const ib_rbt_t *tree)
Return the right most data node in the tree.
Definition: ut0rbt.cc:925
const ib_rbt_node_t * rbt_add_node(ib_rbt_t *tree, ib_rbt_bound_t *parent, const void *value)
Add a new node to the tree, useful for data that is pre-sorted.
Definition: ut0rbt.cc:735
ib_rbt_t * rbt_create_arg_cmp(size_t sizeof_value, ib_rbt_arg_compare compare, void *cmp_arg)
Create an instance of a red black tree, whose comparison function takes an argument.
Definition: ut0rbt.cc:658
const ib_rbt_node_t * rbt_insert(ib_rbt_t *tree, const void *key, const void *value)
Add data to the red black tree, identified by key (no dups yet!)
Definition: ut0rbt.cc:709
ulint rbt_merge_uniq(ib_rbt_t *dst, const ib_rbt_t *src)
Merge the node from dst into src.
Definition: ut0rbt.cc:958
int rbt_search_cmp(const ib_rbt_t *tree, ib_rbt_bound_t *parent, const void *key, ib_rbt_compare compare, ib_rbt_arg_compare arg_compare)
Search for the key, a node will be returned in parent.last, whether it was found or not.
Definition: ut0rbt.cc:872
int(* ib_rbt_compare)(const void *p1, const void *p2)
Definition: ut0rbt.h:54
int rbt_search(const ib_rbt_t *tree, ib_rbt_bound_t *parent, const void *key)
Search for the key, a node will be returned in parent.last, whether it was found or not.
Definition: ut0rbt.cc:837
bool rbt_delete(ib_rbt_t *tree, const void *key)
Delete a node from the red black tree, identified by key.
Definition: ut0rbt.cc:799
bool rbt_validate(const ib_rbt_t *tree)
Verify the integrity of the RB tree.
Definition: ut0rbt.cc:983
const ib_rbt_node_t * rbt_prev(const ib_rbt_t *tree, const ib_rbt_node_t *current)
Return the prev node from current.
Definition: ut0rbt.cc:949