~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_tree.h

  • Committer: Monty Taylor
  • Date: 2008-08-01 22:33:44 UTC
  • mto: (236.1.42 codestyle)
  • mto: This revision was merged to the branch mainline in revision 261.
  • Revision ID: monty@inaugust.com-20080801223344-vzhlflfmtijp1imv
First pass at gettexizing the error messages.

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