File: clb_ddarrays.h

package info (click to toggle)
eprover 3.2.5%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,504 kB
  • sloc: ansic: 104,396; csh: 13,135; python: 11,207; awk: 5,825; makefile: 554; sh: 400
file content (110 lines) | stat: -rw-r--r-- 3,125 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*-----------------------------------------------------------------------

File  : clb_ddarrays.h

Author: Stephan Schulz

Contents

  Dynamic arrays of large data types - at the moment doubles only.

  Copyright 1998, 1999 by the author.
  This code is released under the GNU General Public Licence and
  the GNU Lesser General Public License.
  See the file COPYING in the main E directory for details..
  Run "eprover -h" for contact information.

Changes

<1> Sun Aug  8 22:45:29 GMT 1999
    Copied from clb_pdarrays.h

-----------------------------------------------------------------------*/

#ifndef CLB_DDARRAYS

#define CLB_DDARRAYS

#include <clb_memory.h>


/*---------------------------------------------------------------------*/
/*                    Data type declarations                           */
/*---------------------------------------------------------------------*/

typedef struct ddarraycell
{
   long   size;
   long   grow;
   double *array;
}DDArrayCell, *DDArray_p;


/*---------------------------------------------------------------------*/
/*                Exported Functions and Variables                     */
/*---------------------------------------------------------------------*/

#define DDArrayCellAlloc() (DDArrayCell*)SizeMalloc(sizeof(DDArrayCell))
#define DDArrayCellFree(junk) SizeFree(junk, sizeof(DDArrayCell))

DDArray_p DDArrayAlloc(long init_size, long grow);
void      DDArrayFree(DDArray_p junk);

void      DDArayEnlarge(DDArray_p array, long idx);
static inline double* DDArrayElementRef(DDArray_p array, long idx);


#define   DDArrayAssign(array, idx, value) \
          *DDArrayElementRef((array), (idx)) = (value)

#define   DDArrayElement(array, idx) \
     *DDArrayElementRef((array), (idx))

void      DDArrayAdd(DDArray_p collect, DDArray_p data, long limit);

double    DDArraySelectPart(DDArray_p array, double part, long size);


/*---------------------------------------------------------------------*/
/*                     Inline functions                                */
/*---------------------------------------------------------------------*/


/*-----------------------------------------------------------------------
//
// Function: DDArrayElementRef()
//
//   Return a reference to an element in a dynamic array. This
//   reference is only good until the next call to this function! User
//   programs are expected to use this function only extremely rarely
//   and with special care. Use DDArrayElement()/DDArrayAssign()
//   instead.
//
// Global Variables: -
//
// Side Effects    : May enlarge and move array.
//
/----------------------------------------------------------------------*/

static inline double* DDArrayElementRef(DDArray_p array, long idx)
{
   assert(array);
   assert(idx >= 0);

   if(!(idx < array->size))
   {
      DDArayEnlarge(array, idx);
   }
   return &(array->array[idx]);
}

#endif

/*---------------------------------------------------------------------*/
/*                        End of File                                  */
/*---------------------------------------------------------------------*/