gpp4  1.3.1
ccp4_array.h
Go to the documentation of this file.
1 /*
2  ccp4_array.h: header file for resizable array implementation.
3  Copyright (C) 2002 Kevin Cowtan
4 
5  This library is free software: you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation, either
8  version 3 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with This library. If not, see
17  <http://www.gnu.org/licenses/>.
18 
19 */
20 
69 #ifndef __CCP4_ARRAY_INC
70 #define __CCP4_ARRAY_INC
71 
72 #ifdef __cplusplus
73 extern "C" {
74 #endif
75 
76 #include <stdlib.h>
77 #include <string.h>
78 
80 typedef const void *ccp4_constptr;
82 typedef char *ccp4_byteptr;
84 typedef void *ccp4_ptr;
85 
88 typedef struct ccp4array_base_ {
89  int size;
90  int capacity;
92 
98 #define ccp4array_new(v) ccp4array_new_((ccp4_ptr*)(&v))
99 
106 #define ccp4array_new_size(v,s) ccp4array_new_size_((ccp4_ptr*)(&v),s,sizeof(*v))
107 
116 #define ccp4array_resize(v,s) ccp4array_resize_((ccp4_ptr*)(&v),s,sizeof(*v))
117 
126 #define ccp4array_reserve(v,s) ccp4array_reserve_((ccp4_ptr*)(&v),s,sizeof(*v))
127 
134 #define ccp4array_append(v,d) ccp4array_append_((ccp4_ptr*)(&v),(ccp4_constptr)(&d),sizeof(*v))
135 
143 #define ccp4array_append_n(v,d,n) ccp4array_append_n_((ccp4_ptr*)(&v),(ccp4_constptr)(&d),n,sizeof(*v))
144 
152 #define ccp4array_append_list(v,l,n) ccp4array_append_list_((ccp4_ptr*)(&v),(ccp4_constptr)l,n,sizeof(*v))
153 
161 #define ccp4array_insert(v,i,d) ccp4array_insert_((ccp4_ptr*)(&v),i,(ccp4_constptr)(&d),sizeof(*v))
162 
169 #define ccp4array_delete_ordered(v,i) ccp4array_delete_ordered_((ccp4_ptr*)(&v),i,sizeof(*v))
170 
176 #define ccp4array_delete(v,i) ccp4array_delete_((ccp4_ptr*)(&v),i,sizeof(*v))
177 
182 #define ccp4array_delete_last(v) ccp4array_delete_last_((ccp4_ptr*)(&v),sizeof(*v))
183 
188 #define ccp4array_size(v) ccp4array_size_((ccp4_constptr*)(&v))
189 
194 #define ccp4array_free(v) ccp4array_free_((ccp4_ptr*)(&v))
195 
199 ccp4_ptr ccp4array_new_(ccp4_ptr *p);
203 ccp4_ptr ccp4array_new_size_(ccp4_ptr *p, const int size, const size_t reclen);
207 void ccp4array_resize_(ccp4_ptr *p, const int size, const size_t reclen);
211 void ccp4array_reserve_(ccp4_ptr *p, const int size, const size_t reclen);
215 void ccp4array_append_(ccp4_ptr *p, ccp4_constptr data, const size_t reclen);
219 void ccp4array_append_n_(ccp4_ptr *p, ccp4_constptr data, const int n, const size_t reclen);
223 void ccp4array_append_list_(ccp4_ptr *p, ccp4_constptr data, const int n, const size_t reclen);
227 void ccp4array_insert_(ccp4_ptr *p, const int i, ccp4_constptr data, const size_t reclen);
231 void ccp4array_delete_ordered_(ccp4_ptr *p, const int i, const size_t reclen);
235 void ccp4array_delete_(ccp4_ptr *p, const int i, const size_t reclen);
239 void ccp4array_delete_last_(ccp4_ptr *p, const size_t reclen);
243 int ccp4array_size_(ccp4_constptr *p);
247 void ccp4array_free_(ccp4_ptr *p);
248 
249 #ifdef __cplusplus
250 }
251 #endif
252 
253 #endif /* __CCP4_ARRAY_INC */
254 
255 /*
256  Local variables:
257  mode: font-lock
258  End:
259 */