26 #define MAX_TREE_HEIGHT 64
28 #define ELEMENT_KEY(tree,element)\
29 (tree->offset_to_key ? (void*)((uchar*) element+tree->offset_to_key) :\
30 *((void**) (element+1)))
32 #define tree_set_pointer(element,ptr) *((uchar **) (element+1))=((uchar*) (ptr))
34 #define TREE_NO_DUPS 1
36 typedef enum { left_root_right, right_root_left } TREE_WALK;
37 typedef uint32 element_count;
38 typedef int (*tree_walk_action)(
void *,element_count,
void *);
40 typedef enum { free_init, free_free, free_end } TREE_FREE;
41 typedef void (*tree_element_free)(
void*, TREE_FREE,
const void *);
49 #define ELEMENT_CHILD(element, offs) (*(TREE_ELEMENT**)((char*)element + offs))
54 uint offset_to_key,elements_in_tree,size_of_element;
55 ulong memory_limit, allocated;
57 const void *custom_arg;
60 tree_element_free free;
65 void init_tree(
TREE *tree, ulong default_alloc_size, ulong memory_limit,
67 tree_element_free free_element,
const void *custom_arg);
68 void delete_tree(
TREE*);
69 void reset_tree(
TREE*);
72 #define is_tree_inited(tree) ((tree)->root != 0)
76 const void *custom_arg);
77 void *tree_search(
TREE *tree,
void *key,
const void *custom_arg);
78 int tree_walk(
TREE *tree,tree_walk_action action,
79 void *argument, TREE_WALK visit);
80 int tree_delete(
TREE *tree,
void *key, uint key_size,
const void *custom_arg);
81 void *tree_search_key(
TREE *tree,
const void *key,
83 enum ha_rkey_function flag,
const void *custom_arg);
88 ha_rows tree_record_pos(
TREE *tree,
const void *key,
89 enum ha_rkey_function search_flag,
90 const void *custom_arg);
92 #define TREE_ELEMENT_EXTRA_SIZE (sizeof(TREE_ELEMENT) + sizeof(void*))