~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/my_tree.h

  • Committer: Brian Aker
  • Date: 2010-01-27 18:58:12 UTC
  • Revision ID: brian@gaz-20100127185812-n62n0vwetnx8jrjy
Remove dead code.

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 _tree_h
17
 
#define _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"
 
24
 
18
25
#ifdef  __cplusplus
19
26
extern "C" {
20
27
#endif
21
28
 
22
 
#include <drizzled/base.h>              /* get 'enum ha_rkey_function' */
23
 
 
24
29
/* Worst case tree is half full. This gives use 2^(MAX_TREE_HEIGHT/2) leafs */
25
 
#define MAX_TREE_HEIGHT 64
26
 
 
27
 
#define ELEMENT_KEY(tree,element)\
28
 
(tree->offset_to_key ? (void*)((uchar*) element+tree->offset_to_key) :\
29
 
                        *((void**) (element+1)))
30
 
 
31
 
#define tree_set_pointer(element,ptr) *((uchar **) (element+1))=((uchar*) (ptr))
32
 
 
33
 
#define TREE_NO_DUPS 1
 
30
static const int MAX_TREE_HEIGHT= 64;
 
31
 
 
32
static const int TREE_NO_DUPS= 1;
34
33
 
35
34
typedef enum { left_root_right, right_root_left } TREE_WALK;
36
 
typedef uint32_t element_count;
37
 
typedef int (*tree_walk_action)(void *,element_count,void *);
 
35
typedef int (*tree_walk_action)(void *,uint32_t,void *);
38
36
 
39
37
typedef enum { free_init, free_free, free_end } TREE_FREE;
40
38
typedef void (*tree_element_free)(void*, TREE_FREE, void *);
45
43
         colour:1;                      /* black is marked as 1 */
46
44
} TREE_ELEMENT;
47
45
 
48
 
#define ELEMENT_CHILD(element, offs) (*(TREE_ELEMENT**)((char*)element + offs))
 
46
static const int TREE_ELEMENT_EXTRA_SIZE= (sizeof(TREE_ELEMENT) + sizeof(void*));
 
47
 
49
48
 
50
49
typedef struct st_tree {
51
50
  TREE_ELEMENT *root,null_element;
52
51
  TREE_ELEMENT **parents[MAX_TREE_HEIGHT];
53
 
  uint offset_to_key,elements_in_tree,size_of_element;
54
 
  uint32_t memory_limit, allocated;
 
52
  uint32_t offset_to_key, elements_in_tree, size_of_element;
 
53
  size_t memory_limit;
 
54
  size_t allocated;
55
55
  qsort_cmp2 compare;
56
56
  void *custom_arg;
57
 
  MEM_ROOT mem_root;
 
57
  drizzled::memory::Root mem_root;
58
58
  bool with_delete;
59
59
  tree_element_free free;
60
 
  uint flag;
 
60
  uint32_t flag;
61
61
} TREE;
62
62
 
63
 
        /* Functions on whole tree */
64
 
void init_tree(TREE *tree, uint32_t default_alloc_size, uint32_t memory_limit,
65
 
               int size, qsort_cmp2 compare, bool with_delete,
 
63
/* Functions on whole tree */
 
64
void init_tree(TREE *tree, size_t default_alloc_size, uint32_t memory_limit,
 
65
               uint32_t size, qsort_cmp2 compare, bool with_delete,
66
66
               tree_element_free free_element, void *custom_arg);
67
67
void delete_tree(TREE*);
68
68
void reset_tree(TREE*);
69
 
  /* similar to delete tree, except we do not my_free() blocks in mem_root
70
 
   */
 
69
 
 
70
/* 
 
71
  similar to delete tree, except we do not free() blocks in mem_root
 
72
*/
71
73
#define is_tree_inited(tree) ((tree)->root != 0)
72
74
 
73
 
        /* Functions on leafs */
74
 
TREE_ELEMENT *tree_insert(TREE *tree,void *key, uint key_size, 
 
75
/* Functions on leafs */
 
76
TREE_ELEMENT *tree_insert(TREE *tree,void *key, uint32_t key_size,
75
77
                          void *custom_arg);
76
 
void *tree_search(TREE *tree, void *key, void *custom_arg);
77
78
int tree_walk(TREE *tree,tree_walk_action action,
78
79
              void *argument, TREE_WALK visit);
79
 
int tree_delete(TREE *tree, void *key, uint key_size, void *custom_arg);
80
 
void *tree_search_key(TREE *tree, const void *key, 
 
80
int tree_delete(TREE *tree, void *key, uint32_t key_size, void *custom_arg);
 
81
void *tree_search_key(TREE *tree, const void *key,
81
82
                      TREE_ELEMENT **parents, TREE_ELEMENT ***last_pos,
82
83
                      enum ha_rkey_function flag, void *custom_arg);
83
 
void *tree_search_edge(TREE *tree, TREE_ELEMENT **parents, 
 
84
void *tree_search_edge(TREE *tree, TREE_ELEMENT **parents,
84
85
                        TREE_ELEMENT ***last_pos, int child_offs);
85
 
void *tree_search_next(TREE *tree, TREE_ELEMENT ***last_pos, int l_offs, 
 
86
void *tree_search_next(TREE *tree, TREE_ELEMENT ***last_pos, int l_offs,
86
87
                       int r_offs);
87
 
ha_rows tree_record_pos(TREE *tree, const void *key, 
88
 
                     enum ha_rkey_function search_flag, void *custom_arg);
 
88
ha_rows tree_record_pos(TREE *tree, const void *key,
 
89
                        enum ha_rkey_function search_flag, void *custom_arg);
89
90
 
90
 
#define TREE_ELEMENT_EXTRA_SIZE (sizeof(TREE_ELEMENT) + sizeof(void*))
91
91
 
92
92
#ifdef  __cplusplus
93
93
}
94
94
#endif
95
 
#endif
 
95
 
 
96
#endif /* DRIZZLED_MY_TREE_H */