1 /*-----------------------------------------------------------------------
2
3 File : clb_ddarrays.h
4
5 Author: Stephan Schulz
6
7 Contents
8
9 Dynamic arrays of large data types - at the moment doubles only.
10
11 Copyright 1998, 1999 by the author.
12 This code is released under the GNU General Public Licence and
13 the GNU Lesser General Public License.
14 See the file COPYING in the main E directory for details..
15 Run "eprover -h" for contact information.
16
17 Changes
18
19 <1> Sun Aug 8 22:45:29 GMT 1999
20 Copied from clb_pdarrays.h
21
22 -----------------------------------------------------------------------*/
23
24 #ifndef CLB_DDARRAYS
25
26 #define CLB_DDARRAYS
27
28 #include <clb_memory.h>
29
30
31 /*---------------------------------------------------------------------*/
32 /* Data type declarations */
33 /*---------------------------------------------------------------------*/
34
35 typedef struct ddarraycell
36 {
37 long size;
38 long grow;
39 double *array;
40 }DDArrayCell, *DDArray_p;
41
42
43 /*---------------------------------------------------------------------*/
44 /* Exported Functions and Variables */
45 /*---------------------------------------------------------------------*/
46
47 #define DDArrayCellAlloc() (DDArrayCell*)SizeMalloc(sizeof(DDArrayCell))
48 #define DDArrayCellFree(junk) SizeFree(junk, sizeof(DDArrayCell))
49
50 DDArray_p DDArrayAlloc(long init_size, long grow);
51 void DDArrayFree(DDArray_p junk);
52
53 void DDArayEnlarge(DDArray_p array, long idx);
54 static __inline__ double* DDArrayElementRef(DDArray_p array, long idx);
55
56
57 #define DDArrayAssign(array, idx, value) \
58 *DDArrayElementRef((array), (idx)) = (value)
59
60 #define DDArrayElement(array, idx) \
61 *DDArrayElementRef((array), (idx))
62
63 void DDArrayAdd(DDArray_p collect, DDArray_p data, long limit);
64
65 double DDArraySelectPart(DDArray_p array, double part, long size);
66
67
68 /*---------------------------------------------------------------------*/
69 /* Inline functions */
70 /*---------------------------------------------------------------------*/
71
72
73 /*-----------------------------------------------------------------------
74 //
75 // Function: DDArrayElementRef()
76 //
77 // Return a reference to an element in a dynamic array. This
78 // reference is only good until the next call to this function! User
79 // programs are expected to use this function only extremely rarely
80 // and with special care. Use DDArrayElement()/DDArrayAssign()
81 // instead.
82 //
83 // Global Variables: -
84 //
85 // Side Effects : May enlarge and move array.
86 //
87 /----------------------------------------------------------------------*/
88
DDArrayElementRef(DDArray_p array,long idx)89 static __inline__ double* DDArrayElementRef(DDArray_p array, long idx)
90 {
91 assert(array);
92 assert(idx >= 0);
93
94 if(!(idx < array->size))
95 {
96 DDArayEnlarge(array, idx);
97 }
98 return &(array->array[idx]);
99 }
100
101 #endif
102
103 /*---------------------------------------------------------------------*/
104 /* End of File */
105 /*---------------------------------------------------------------------*/
106
107
108
109
110
111