|
static void | delete_tree_element (TREE *, TREE_ELEMENT *) |
|
static int | tree_walk_left_root_right (TREE *, TREE_ELEMENT *, tree_walk_action, void *) |
|
static int | tree_walk_right_root_left (TREE *, TREE_ELEMENT *, tree_walk_action, void *) |
|
static void | left_rotate (TREE_ELEMENT **parent, TREE_ELEMENT *leaf) |
|
static void | right_rotate (TREE_ELEMENT **parent, TREE_ELEMENT *leaf) |
|
static void | rb_insert (TREE *tree, TREE_ELEMENT ***parent, TREE_ELEMENT *leaf) |
|
static void | rb_delete_fixup (TREE *tree, TREE_ELEMENT ***parent) |
|
static int | test_rb_tree (TREE_ELEMENT *element) |
|
void | init_tree (TREE *tree, ulong memory_limit, int element_size, qsort2_cmp compare, bool with_delete, tree_element_free free_element, const void *custom_arg) |
|
static void | free_tree (TREE *tree, bool reuse) |
|
void | delete_tree (TREE *tree) |
|
void | reset_tree (TREE *tree) |
|
TREE_ELEMENT * | tree_insert (TREE *tree, void *key, uint key_size, const void *custom_arg) |
|
int | tree_delete (TREE *tree, void *key, uint key_size, const void *custom_arg) |
|
void * | tree_search (TREE *tree, void *key, const void *custom_arg) |
|
void * | tree_search_key (TREE *tree, const void *key, TREE_ELEMENT **parents, TREE_ELEMENT ***last_pos, enum ha_rkey_function flag, const void *custom_arg) |
|
void * | tree_search_edge (TREE *tree, TREE_ELEMENT **parents, TREE_ELEMENT ***last_pos, int child_offs) |
|
void * | tree_search_next (TREE *tree, TREE_ELEMENT ***last_pos, int l_offs, int r_offs) |
|
ha_rows | tree_record_pos (TREE *tree, const void *key, enum ha_rkey_function flag, const void *custom_arg) |
|
int | tree_walk (TREE *tree, tree_walk_action action, void *argument, TREE_WALK visit) |
|
Code for handling red-black (balanced) binary trees.
key in tree is allocated according to following:
1) If size < 0 then tree will not allocate keys and only a pointer to each key is saved in tree. compare and search functions uses and returns key-pointer
2) If size == 0 then there are two options:
- key_size != 0 to tree_insert: The key will be stored in the tree.
- key_size == 0 to tree_insert: A pointer to the key is stored. compare and search functions uses and returns key-pointer.
3) if key_size is given to init_tree then each node will continue the key and calls to insert_key may increase length of key. if key_size > sizeof(pointer) and key_size is a multiple of 8 (double align) then key will be put on a 8 aligned address. Else the key will be on address (element+1). This is transparent for user compare and search functions uses a pointer to given key-argument.
- If you use a free function for tree-elements and you are freeing the element itself, you should use key_size = 0 to init_tree and tree_search
The actual key in TREE_ELEMENT is saved as a pointer or after the TREE_ELEMENT struct. If one uses only pointers in tree one can use tree_set_pointer() to change address of data.