CUBRID Engine  latest
adjustable_array.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * adjustable_array.h : adjustable array definitions
22  *
23  */
24 
25 #ifndef _ADJUSTABLE_ARRAY_H_
26 #define _ADJUSTABLE_ARRAY_H_
27 
28 #ident "$Id$"
29 
30 #include <stdio.h>
31 #include <stdlib.h>
32 
33 #include "porting.h"
34 
35 #define ADJ_AR_EOA -1
36 
38 {
51 };
53 
54 typedef struct adj_array ADJ_ARRAY;
55 struct adj_array
56 {
57  int cur_length; /* current array length */
58  int max_length; /* maximum elements in buffer */
59  int min_length; /* minimum elements in buffer */
60  int element_size; /* size of array element in bytes */
61  void *buffer; /* current array buffer */
62  float rate; /* growth rate (>= 1.0) */
63 };
64 
65 extern const char *adj_ar_concat_strings (const char *string1, const char *string2, ...);
66 
67 extern ADJ_ARRAY *adj_ar_new (int element_size, int min, float growth_rate);
68 
69 extern void adj_ar_free (ADJ_ARRAY * adj_array_p);
70 
71 extern int adj_ar_reset (ADJ_ARRAY * adj_array_p, int element_size, int min, float growth_rate);
72 
73 extern int adj_ar_initialize (ADJ_ARRAY * adj_array_p, const void *initial, int initial_length);
74 
75 extern int adj_ar_replace (ADJ_ARRAY * adj_array_p, const void *src, int src_length, int start, int end);
76 
77 extern int adj_ar_remove (ADJ_ARRAY * adj_array_p, int start, int end);
78 
79 extern int adj_ar_insert (ADJ_ARRAY * adj_array_p, const void *src, int src_length, int start);
80 
81 extern int adj_ar_append (ADJ_ARRAY * adj_array_p, const void *src, int src_length);
82 
83 extern void *adj_ar_get_buffer (const ADJ_ARRAY * adj_array_p);
84 
85 extern int adj_ar_length (const ADJ_ARRAY * adj_array_p);
86 
87 #if defined(ENABLE_UNUSED_FUNCTION)
88 extern void *adj_ar_get_nth_buffer (const ADJ_ARRAY * adj_array_p, int n);
89 #endif
90 
91 #endif /* _ADJUSTABLE_ARRAY_H_ */
int adj_ar_initialize(ADJ_ARRAY *adj_array_p, const void *initial, int initial_length)
int adj_ar_reset(ADJ_ARRAY *adj_array_p, int element_size, int min, float growth_rate)
const char * adj_ar_concat_strings(const char *string1, const char *string2,...)
int adj_ar_length(const ADJ_ARRAY *adj_array_p)
void adj_ar_free(ADJ_ARRAY *adj_array_p)
int adj_ar_remove(ADJ_ARRAY *adj_array_p, int start, int end)
#define min(a, b)
void * adj_ar_get_buffer(const ADJ_ARRAY *adj_array_p)
enum adj_err_code ADJ_ERR_CODE
int adj_ar_replace(ADJ_ARRAY *adj_array_p, const void *src, int src_length, int start, int end)
int adj_ar_insert(ADJ_ARRAY *adj_array_p, const void *src, int src_length, int start)
ADJ_ARRAY * adj_ar_new(int element_size, int min, float growth_rate)
int adj_ar_append(ADJ_ARRAY *adj_array_p, const void *src, int src_length)
adj_err_code