13
13
along with this program; if not, write to the Free Software
14
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#ifndef MYSYS_MY_TREE_H
17
#define MYSYS_MY_TREE_H
16
#ifndef DRIZZLED_MY_TREE_H
17
#define DRIZZLED_MY_TREE_H
21
#include "drizzled/base.h" /* get 'enum ha_rkey_function' */
22
#include "drizzled/qsort_cmp.h"
23
#include "drizzled/memory/root.h"
23
#include <drizzled/base.h> /* get 'enum ha_rkey_function' */
24
#include <mysys/my_sys.h>
29
typedef struct st_mem_root MEM_ROOT;
26
31
/* Worst case tree is half full. This gives use 2^(MAX_TREE_HEIGHT/2) leafs */
27
#define MAX_TREE_HEIGHT 64
29
#define ELEMENT_KEY(tree,element)\
30
(tree->offset_to_key ? (void*)((unsigned char*) element+tree->offset_to_key) :\
31
*((void**) (element+1)))
33
#define tree_set_pointer(element,ptr) *((unsigned char **) (element+1))=((unsigned char*) (ptr))
35
#define TREE_NO_DUPS 1
32
static const int MAX_TREE_HEIGHT= 64;
34
static const int TREE_NO_DUPS= 1;
37
36
typedef enum { left_root_right, right_root_left } TREE_WALK;
38
typedef uint32_t element_count;
39
typedef int (*tree_walk_action)(void *,element_count,void *);
37
typedef int (*tree_walk_action)(void *,uint32_t,void *);
41
39
typedef enum { free_init, free_free, free_end } TREE_FREE;
42
40
typedef void (*tree_element_free)(void*, TREE_FREE, void *);
47
45
colour:1; /* black is marked as 1 */
50
#define ELEMENT_CHILD(element, offs) (*(TREE_ELEMENT**)((char*)element + offs))
48
static const int TREE_ELEMENT_EXTRA_SIZE= (sizeof(TREE_ELEMENT) + sizeof(void*));
52
51
typedef struct st_tree {
53
52
TREE_ELEMENT *root,null_element;
91
90
ha_rows tree_record_pos(TREE *tree, const void *key,
92
91
enum ha_rkey_function search_flag, void *custom_arg);
94
#define TREE_ELEMENT_EXTRA_SIZE (sizeof(TREE_ELEMENT) + sizeof(void*))
100
#endif /* MYSYS_MY_TREE_H */
98
#endif /* DRIZZLED_MY_TREE_H */