~jaypipes/drizzle/subscriber-plugin

« back to all changes in this revision

Viewing changes to drizzled/my_tree.h

Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 */
15
15
 
16
 
#ifndef MYSYS_MY_TREE_H
17
 
#define MYSYS_MY_TREE_H
 
16
#ifndef DRIZZLED_MY_TREE_H
 
17
#define DRIZZLED_MY_TREE_H
 
18
 
 
19
#include <unistd.h>
 
20
 
 
21
#include "drizzled/base.h"              /* get 'enum ha_rkey_function' */
 
22
#include "drizzled/qsort_cmp.h"
 
23
#include "drizzled/memory/root.h"
18
24
 
19
25
#ifdef  __cplusplus
20
26
extern "C" {
21
27
#endif
22
28
 
23
 
#include <drizzled/base.h>              /* get 'enum ha_rkey_function' */
24
 
#include <mysys/my_sys.h>
 
29
typedef struct st_mem_root MEM_ROOT;
25
30
 
26
31
/* Worst case tree is half full. This gives use 2^(MAX_TREE_HEIGHT/2) leafs */
27
 
#define MAX_TREE_HEIGHT 64
28
 
 
29
 
#define ELEMENT_KEY(tree,element)\
30
 
(tree->offset_to_key ? (void*)((unsigned char*) element+tree->offset_to_key) :\
31
 
                        *((void**) (element+1)))
32
 
 
33
 
#define tree_set_pointer(element,ptr) *((unsigned char **) (element+1))=((unsigned char*) (ptr))
34
 
 
35
 
#define TREE_NO_DUPS 1
 
32
static const int MAX_TREE_HEIGHT= 64;
 
33
 
 
34
static const int TREE_NO_DUPS= 1;
36
35
 
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 *);
40
38
 
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 */
48
46
} TREE_ELEMENT;
49
47
 
50
 
#define ELEMENT_CHILD(element, offs) (*(TREE_ELEMENT**)((char*)element + offs))
 
48
static const int TREE_ELEMENT_EXTRA_SIZE= (sizeof(TREE_ELEMENT) + sizeof(void*));
 
49
 
51
50
 
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);
93
92
 
94
 
#define TREE_ELEMENT_EXTRA_SIZE (sizeof(TREE_ELEMENT) + sizeof(void*))
95
93
 
96
94
#ifdef  __cplusplus
97
95
}
98
96
#endif
99
97
 
100
 
#endif /* MYSYS_MY_TREE_H */
 
98
#endif /* DRIZZLED_MY_TREE_H */