Changeset 485 for trunk/psLib/src/collections/psArray.h
- Timestamp:
- Apr 20, 2004, 2:18:05 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/collections/psArray.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psArray.h
r433 r485 1 /* remove this file when there is a valid psArray.h */ 2 3 typedef struct { 4 int n; 5 float *arr; 6 } psFloatArray; 7 8 typedef struct { 9 int n; 10 int *arr; 11 } psIntArray; 12 13 psFloatArray *psFloatArrayAlloc(int nalloc); 14 int psFreeFloatArray(psFloatArray *inArray); 15 psIntArray *psIntArrayAlloc(int nalloc); 1 /** @file psArray.h 2 * 3 * @brief Contains support for basic array types 4 * 5 * The types of basic one dimensional arrays defined include: int, float, double, complex float, and 6 * void *. 7 * 8 * @author Ross Harman, MHPCC 9 * 10 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-04-21 00:18:05 $ 12 * 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 14 */ 15 16 #ifndef PS_ARRAY_H 17 #define PS_ARRAY_H 18 19 #include <complex.h> 20 21 /******************************************************************************/ 22 /* DEFINE STATEMENTS */ 23 /******************************************************************************/ 24 25 // None 26 27 /******************************************************************************/ 28 /* TYPE DEFINITIONS */ 29 /******************************************************************************/ 30 31 /** Types of the elements of vectors, images, etc. 32 * 33 * The basic types of the primitives used by psLib are defined within this enum. This enum is used by the psType struct. 34 * 35 */ 36 typedef enum { 37 PS_TYPE_CHAR, ///< Character. 38 PS_TYPE_SHORT, ///< Short integer. 39 PS_TYPE_INT, ///< Integer. 40 PS_TYPE_LONG, ///< Long integer. 41 PS_TYPE_UCHAR, ///< Unsigned character. 42 PS_TYPE_USHORT, ///< Unsigned short integer. 43 PS_TYPE_UINT, ///< Unsigned integer. 44 PS_TYPE_ULONG, ///< Unsigned long integer. 45 PS_TYPE_FLOAT, ///< Floating point. 46 PS_TYPE_DOUBLE, ///< Double-precision floating point. 47 PS_TYPE_COMPLEX, ///< Complex numbers consisting of floating point. 48 PS_TYPE_OTHER, ///< Something else that's not supported for arithmetic. 49 } psElemType; 50 51 /** Dimensions of a data type. 52 * 53 * The dimensions of containers used by psLib are defined within this enum. This enum is used by the psType struct. 54 * 55 */ 56 typedef enum { 57 PS_DIMEN_SCALAR, ///< Scalar. 58 PS_DIMEN_VECTOR, ///< Vector. 59 PS_DIMEN_TRANSV, ///< Transposed vector. 60 PS_DIMEN_IMAGE, ///< Image. 61 PS_DIMEN_OTHER ///< Something else that's not supported for arithmetic. 62 } psDimen; 63 64 /** The type of a data type. 65 * 66 * All psLib complex types consist of primitive components. This struct provides the description of those 67 * primitives. 68 * 69 */ 70 typedef struct 71 { 72 psElemType type; ///< Primitive type. 73 psDimen dimen; ///< Dimensionality. 74 } 75 psType; 76 77 /** An array of integers. 78 * 79 * Struct for maintaining an array of integer numbers. 80 * 81 */ 82 typedef struct 83 { 84 psType type; ///< Type of data. THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT! 85 int nalloc; ///< Total number of elements available. 86 int n; ///< Number of elements in use. 87 int *arr; ///< Array data. 88 } 89 psIntArray; 90 91 /** An array of floats. 92 * 93 * Struct for maintaining an array of floating point numbers. 94 * 95 */ 96 typedef struct 97 { 98 psType type; ///< Type of data. THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT! 99 int nalloc; ///< Total number of elements available. 100 int n; ///< Number of elements in use. 101 float *arr; ///< Array data. 102 } 103 psFloatArray; 104 105 /*****************************************************************************/ 106 /* FUNCTION PROTOTYPES */ 107 /*****************************************************************************/ 108 109 /** Allocate an integer array */ 110 psIntArray *psIntArrayAlloc( 111 int nalloc ///< Total number of elements to make available 112 ); 113 114 /** Reallocate an integer array */ 115 psIntArray *psIntArrayRealloc( 116 psIntArray *myArray, ///< Array to reallocate. 117 int nalloc ///< Total number of elements to make available. 118 ); 119 120 121 /** Deallocate an integer array */ 122 void psIntArrayFree( 123 psIntArray *restrict myArray ///< Array to free 124 ); 125 126 /** Allocate a float array. 127 * 128 * Uses psLib memory allocation functions to create an array of floats as defined by the psFloatArray struct. 129 * 130 */ 131 psFloatArray *psFloatArrayAlloc( 132 int nalloc ///< Total number of elements to make available. 133 ); 134 135 /** Reallocate a float array. 136 * 137 * Uses psLib memory allocation functions to reallocate an array of floats as defined by the psFloatArray 138 * struct. 139 * 140 */ 141 psFloatArray *psFloatArrayRealloc( 142 psFloatArray *myArray, ///< Array to reallocate. 143 int nalloc ///< Total number of elements to make available. 144 ); 145 146 /** Deallocate a float array 147 * 148 * Uses psLib memory allocation functions to deallocate an array of floats as defined by the psFloatArray 149 * struct. 150 * 151 */ 152 void psFloatArrayFree( 153 psFloatArray *restrict myArray ///< Array to free 154 ); 155 156 /** An array of complex numbers. 157 * 158 * Struct for maintaining an array of complex numbers. 159 * 160 */ 161 typedef struct 162 { 163 psType type; ///< Type of data. THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT! 164 int size; ///< Total number of elements available. 165 int n; ///< Number of elements in use 166 complex float *arr; ///< Array data. 167 } 168 psComplexArray; 169 170 /** Constructor \ingroup DataGroup */ 171 psComplexArray *psComplexArrayAlloc(int nalloc) ///< Total number of elements to make available 172 ; 173 174 /** Reallocator \ingroup DataGroup */ 175 psComplexArray *psComplexArrayRealloc(psComplexArray *myArray, ///< Array to reallocate 176 int nalloc) ///< Total number of elements to make available 177 ; 178 179 /** Destructor \ingroup DataGroup */ 180 void psComplexArrayFree(psComplexArray *restrict myArray) ///< Array to free 181 ; 182 183 184 /************************************************************************************************************/ 185 186 /** An array of double-precision real numbers */ 187 typedef struct 188 { 189 psType type; ///< Type of data. THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT! 190 int nalloc; ///< Total number of elements available 191 int n; ///< Number of elements in use 192 double *arr; ///< The array data 193 } 194 psDoubleArray; 195 196 /** Constructor \ingroup DataGroup */ 197 psDoubleArray *psDoubleArrayAlloc(int nalloc) ///< Total number of elements to make available 198 ; 199 200 /** Reallocator \ingroup DataGroup */ 201 psDoubleArray *psDoubleArrayRealloc(psDoubleArray *myArray, ///< Array to reallocate 202 int nalloc) ///< Total number of elements to make available 203 ; 204 205 /** Destructor \ingroup DataGroup */ 206 void psDoubleArrayFree(psDoubleArray *restrict myArray) ///< Array to free 207 ; 208 209 /** Array of pointers to void. 210 * psVoidPtrArray is special, as it needs to have a destructor that 211 * accepts a destructor for the array elements 212 */ 213 typedef struct 214 { 215 int n; ///< Number of elements in use 216 int nalloc; ///< Number of total elements 217 void **arr; ///< The elements 218 } 219 psVoidPtrArray; 220 221 /** Constructor \ingroup DataGroup */ 222 psVoidPtrArray *psVoidPtrArrayAlloc(int nalloc) ///< Number of elements to use 223 ; 224 225 /** Reallocate \ingroup DataGroup */ 226 psVoidPtrArray *psVoidPtrArrayRealloc(psVoidPtrArray *arr, ///< Array to reallocate 227 int nalloc) ///< Number of elements 228 ; 229 230 /** Destructor \ingroup DataGroup */ 231 void psVoidPtrArrayFree(psVoidPtrArray *arr, ///< array to destroy 232 void (*elemFree)(void *)) ///< destructor for array data 233 ; 234 235 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
