IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 21, 2004, 8:53:10 AM (22 years ago)
Author:
harman
Message:

Added other data types

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/collections/psArray.h

    r486 r493  
    88 *  @author Ross Harman, MHPCC
    99 *   
    10  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-04-21 00:40:32 $
     10 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-04-21 18:53:10 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3535 */
    3636typedef 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.
     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.
    4949} psElemType;
    5050
     
    5555 */
    5656typedef 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.
     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.
    6262} psDimen;
    6363
     
    7070typedef struct
    7171{
    72     psElemType type;  ///< Primitive type.
    73     psDimen dimen;   ///< Dimensionality.
     72    psElemType type;    ///< Primitive type.
     73    psDimen dimen;      ///< Dimensionality.
    7474}
    7575psType;
     
    7878 *
    7979 * 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.
    9480 *
    9581 */
     
    9985    int nalloc;     ///< Total number of elements available.
    10086    int n;          ///< Number of elements in use.
     87    int *arr;       ///< Array data.
     88}
     89psIntArray;
     90
     91/** An array of floats.
     92 *
     93 * Struct for maintaining an array of single precision floating point numbers.
     94 *
     95 */
     96typedef struct
     97{
     98    psType type;    ///< Type of data.
     99    int nalloc;     ///< Total number of elements available.
     100    int n;          ///< Number of elements in use.
    101101    float *arr;     ///< Array data.
    102102}
     
    110110typedef struct
    111111{
    112     psType type;    ///< Type of data.  THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
     112    psType type;    ///< Type of data.
    113113    int nalloc;     ///< Total number of elements available.
    114114    int n;          ///< Number of elements in use.
     
    117117psDoubleArray;
    118118
     119/** An array of complex numbers.
     120 *
     121 * Struct for maintaining an array of single precision floating point complex numbers.
     122 *
     123 */
     124typedef struct
     125{
     126    psType type;        ///< Type of data.
     127    int nalloc;         ///< Total number of elements available.
     128    int n;              ///< Number of elements in use
     129    complex float *arr; ///< Array data.
     130}
     131psComplexArray;
     132
     133/** An array of void pointers.
     134 *
     135 * Struct for maintaining an array of void pointers. This struct needs a deallocation function that accepts
     136 * deallocation of the array elements.
     137 *
     138 */
     139typedef struct
     140{
     141    psType type;    ///< Type of data.
     142    int nalloc;     ///< Number of total elements.
     143    int n;          ///< Number of elements in use.
     144    void **arr;     ///< Aray data.
     145}
     146psVoidPtrArray;
     147
     148
    119149/*****************************************************************************/
    120150/* FUNCTION PROTOTYPES                                                       */
     
    127157 */
    128158psIntArray *psIntArrayAlloc(
    129     int nalloc  ///< Total number of elements to make available
     159    int nalloc  ///< Total number of elements to make available.
    130160);
    131161
     
    149179 */
    150180void psIntArrayFree(
    151     psIntArray *restrict myArray    ///< Array to free
     181    psIntArray *restrict psArr  ///< Array to free.
    152182);
    153183
     
    168198 */
    169199psFloatArray *psFloatArrayRealloc(
    170     psFloatArray *myArray,  ///< Array to reallocate.
     200    psFloatArray *psArr,  ///< Array to reallocate.
    171201    int nalloc              ///< Total number of elements to make available.
    172202);
    173203
    174 /** Deallocate a float array
     204/** Deallocate a float array.
    175205 *
    176206 * Uses psLib memory allocation functions to deallocate an array of floats as defined by the psFloatArray
     
    179209 */
    180210void psFloatArrayFree(
    181     psFloatArray *restrict myArray  ///< Array to free
    182 );
    183 
    184 /** Allocate a Double array.
     211    psFloatArray *restrict myArray  ///< Array to free.
     212);
     213
     214/** Allocate a double array.
    185215 *
    186216 * Uses psLib memory allocation functions to create an array of doubles as defined by the psDoubleArray
     
    192222);
    193223
    194 /** Reallocate a Double array.
     224/** Reallocate a double array.
    195225 *
    196226 * Uses psLib memory allocation functions to reallocate an array of Doubles as defined by the psDoubleArray
     
    199229 */
    200230psDoubleArray *psDoubleArrayRealloc(
    201     psDoubleArray *myArray, ///< Array to reallocate.
     231    psDoubleArray *psArr, ///< Array to reallocate.
    202232    int nalloc              ///< Total number of elements to make available.
    203233);
    204234
    205 /** Deallocate a Double array
     235/** Deallocate a double array.
    206236 *
    207237 * Uses psLib memory allocation functions to deallocate an array of doubles as defined by the psDoubleArray
     
    210240 */
    211241void psDoubleArrayFree(
    212     psDoubleArray *restrict myArray  ///< Array to free
    213 );
    214 
    215 
    216 
    217 
    218 
    219 
    220 
    221 
    222 /** An array of complex numbers.
    223  *
    224  * Struct for maintaining an array of complex numbers.
    225  *
    226  */
    227 typedef struct
    228 {
    229     psType type;  ///< Type of data. THIS STRUCT ELEMENT MUST BE FIRST IN THE STRUCT!
    230     int size;   ///< Total number of elements available.
    231     int n;    ///< Number of elements in use
    232     complex float *arr; ///< Array data.
    233 }
    234 psComplexArray;
    235 
    236 /** Constructor \ingroup DataGroup */
    237 psComplexArray *psComplexArrayAlloc(int nalloc) ///< Total number of elements to make available
     242    psDoubleArray *restrict psArr  ///< Array to free.
     243);
     244
     245/** Allocate a complex array.
     246 *
     247 * Uses psLib memory allocation functions to create an array of single precision floating point complex
     248 * numbers as defined by the psComplexArray struct.
     249 *
     250 */
     251psComplexArray *psComplexArrayAlloc(int nalloc) ///< Total number of elements to make available.
    238252;
    239253
    240 /** Reallocator \ingroup DataGroup */
    241 psComplexArray *psComplexArrayRealloc(psComplexArray *myArray, ///< Array to reallocate
    242                                       int nalloc) ///< Total number of elements to make available
    243 ;
    244 
    245 /** Destructor \ingroup DataGroup */
    246 void psComplexArrayFree(psComplexArray *restrict myArray) ///< Array to free
    247 ;
    248 
    249 
    250 
    251 
    252 /** Array of pointers to void.
    253  *  psVoidPtrArray is special, as it needs to have a destructor that
    254  *  accepts a destructor for the array elements
    255  */
    256 typedef struct
    257 {
    258     int n;    ///< Number of elements in use
    259     int nalloc;    ///< Number of total elements
    260     void **arr;    ///< The elements
    261 }
    262 psVoidPtrArray;
    263 
    264 /** Constructor \ingroup DataGroup */
    265 psVoidPtrArray *psVoidPtrArrayAlloc(int nalloc) ///< Number of elements to use
    266 ;
    267 
    268 /** Reallocate \ingroup DataGroup */
    269 psVoidPtrArray *psVoidPtrArrayRealloc(psVoidPtrArray *arr, ///< Array to reallocate
    270                                       int nalloc) ///< Number of elements
    271 ;
    272 
    273 /** Destructor \ingroup DataGroup */
    274 void psVoidPtrArrayFree(psVoidPtrArray *arr, ///< array to destroy
    275                         void (*elemFree)(void *)) ///< destructor for array data
    276 ;
     254/** Reallocate a complex array.
     255 *
     256 * Uses psLib memory allocation functions to reallocate an array of single precision floating point complex
     257 * numbers as defined by the psComplexArray struct.
     258 *
     259 */
     260psComplexArray *psComplexArrayRealloc(
     261    psComplexArray *myArray,    ///< Array to reallocate.
     262    int nalloc                  ///< Total number of elements to make available.
     263);
     264
     265/** Deallocate a complex array.
     266 *
     267 * Uses psLib memory allocation functions to deallocate an array of single precision floating point complex
     268 * numbers as defined by the psComplexArray struct.
     269 *
     270 */
     271void psComplexArrayFree(
     272    psComplexArray *restrict psArr  ///< Array to free.
     273);
     274
     275/** Allocate a void pointer array.
     276 *
     277 * Uses psLib memory allocation functions to create an array of void pointers as defined by the psVoidPtrArray
     278 * struct.
     279 *
     280 */
     281psVoidPtrArray *psVoidPtrArrayAlloc(
     282    int nalloc  ///< Number of elements to use.
     283);
     284
     285/** Reallocate a void pointer array.
     286 *
     287 * Uses psLib memory allocation functions to reallocate an array of void pointers as defined by the
     288 * psVoidPtrArray struct.
     289 *
     290 */
     291psVoidPtrArray *psVoidPtrArrayRealloc(
     292    psVoidPtrArray *psArr,  ///< Array to reallocate.
     293    int nalloc              ///< Number of elements.
     294);
     295
     296/** Deallocate a void pointer array.
     297 *
     298 * Uses psLib memory allocation functions to deallocate an array of void pointers as defined by the
     299 * psVoidPtrArray struct.
     300 *
     301 */
     302void psVoidPtrArrayFree(
     303    psVoidPtrArray *restrict psArr,     ///< Array to destroy.
     304    void (*elemFree)(void *)            ///< Callback function responsible for removing array data.
     305);
    277306
    278307#endif
Note: See TracChangeset for help on using the changeset viewer.