~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/dynamic_array.h

  • Committer: Brian Aker
  • Date: 2009-07-11 07:38:37 UTC
  • mto: This revision was merged to the branch mainline in revision 1093.
  • Revision ID: brian@gaz-20090711073837-2t11jeg84kd40n8r
Sorting methods into class files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* - mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 MySQL
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 */
 
20
 
 
21
#ifndef MYSYS_DYNAMIC_ARRAY_H
 
22
#define MYSYS_DYNAMIC_ARRAY_H
 
23
 
 
24
typedef struct st_dynamic_array
 
25
{
 
26
  unsigned char *buffer;
 
27
  size_t elements,max_element;
 
28
  uint32_t alloc_increment;
 
29
  uint32_t size_of_element;
 
30
} DYNAMIC_ARRAY;
 
31
 
 
32
#define my_init_dynamic_array(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D)
 
33
#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D)
 
34
#define my_init_dynamic_array2(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E)
 
35
#define my_init_dynamic_array2_ci(A,B,C,D,E) init_dynamic_array2(A,B,C,D,E)
 
36
 
 
37
extern bool init_dynamic_array2(DYNAMIC_ARRAY *array,uint32_t element_size,
 
38
                                   void *init_buffer, uint32_t init_alloc,
 
39
                                   uint32_t alloc_increment);
 
40
/* init_dynamic_array() function is deprecated */
 
41
extern bool init_dynamic_array(DYNAMIC_ARRAY *array,uint32_t element_size,
 
42
                                  uint32_t init_alloc,uint32_t alloc_increment);
 
43
extern bool insert_dynamic(DYNAMIC_ARRAY *array,unsigned char * element);
 
44
extern unsigned char *alloc_dynamic(DYNAMIC_ARRAY *array);
 
45
extern unsigned char *pop_dynamic(DYNAMIC_ARRAY*);
 
46
extern bool set_dynamic(DYNAMIC_ARRAY *array,unsigned char * element,uint32_t array_index);
 
47
extern bool allocate_dynamic(DYNAMIC_ARRAY *array, uint32_t max_elements);
 
48
extern void get_dynamic(DYNAMIC_ARRAY *array,unsigned char * element,uint32_t array_index);
 
49
extern void delete_dynamic(DYNAMIC_ARRAY *array);
 
50
extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint32_t array_index);
 
51
extern void freeze_size(DYNAMIC_ARRAY *array);
 
52
extern int  get_index_dynamic(DYNAMIC_ARRAY *array, unsigned char * element);
 
53
#define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element)
 
54
#define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
 
55
#define push_dynamic(A,B) insert_dynamic((A),(B))
 
56
#define reset_dynamic(array) ((array)->elements= 0)
 
57
#define sort_dynamic(A,cmp) my_qsort((A)->buffer, (A)->elements, (A)->size_of_element, (cmp))
 
58
 
 
59
 
 
60
#endif /* MYSYS_DYNAMIC_ARRAY_H */