Changeset 450
- Timestamp:
- Apr 19, 2004, 10:10:46 AM (22 years ago)
- Location:
- trunk/psLib/src/collections
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psSort.c
r438 r450 1 /** @file psSort. h2 * 3 * @brief Sorts a n array of floats1 /** @file psSort.c 2 * 3 * @brief Sorts arrays 4 4 * 5 5 * The psSort functions use the qsort() stdlib function with a user-defined callback to sort an array of … … 14 14 * @author Ross Harman, MHPCC 15 15 * 16 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $17 * @date $Date: 2004-04-1 7 02:43:59$16 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2004-04-19 20:10:46 $ 18 18 * 19 19 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 32 32 #include "psArray.h" 33 33 #include "psSort.h" 34 #include "psError.h" 34 35 35 36 /******************************************************************************/ … … 80 81 81 82 if(x == NULL || y == NULL) { 82 p rintf("Null input argument\n");83 psError(__func__, " : Line %d - Null input argument: x=%d y=%d\n", __LINE__, x, y); 83 84 } 84 85 … … 87 88 88 89 if(item1 == NULL || item2 == NULL) { 89 p rintf("Improper cast to float\n");90 psError(__func__, " : Line %d - Improper cast to float: item1=%d item2=%d\n", __LINE__, item1, item2); 90 91 } 91 92 … … 101 102 } 102 103 103 /** Sort an array of floats. 104 * 105 * Sorts an array of floats in ascendin order with the qsort() stdlib function. 106 * 107 * @return psFloatArray*: Pointer to sorted psFloatArray. 108 */ 109 104 /*****************************************************************************/ 105 /* FUNCTION IMPLEMENTATION - PUBLIC */ 106 /*****************************************************************************/ 107 110 108 psFloatArray *psSort( 111 109 psFloatArray *restrict outArray, /**< Sorted output array. */ … … 121 119 122 120 if(outArray == NULL) { 123 p rintf("NULL output array n");121 psError(__func__, " : Line %d - Null output array\n", __LINE__); 124 122 return outArray; 125 123 } 126 124 127 125 if(inArray == NULL) { 128 p rintf("NULL input array\n");126 psError(__func__, " : Line %d - Null input array\n", __LINE__); 129 127 return outArray; 130 128 } … … 138 136 139 137 if(inN != outN) { 140 printf("Input and output array sizes are not equal"); 138 psError(__func__, " : Line %d - Input and output array sizes are not equal: in=%d out=%d\n", __LINE__, 139 inN, outN); 141 140 return outArray; 142 141 } … … 152 151 return outArray; 153 152 } 154 155 /** Creates an array of indices based on sort odred of float array.156 *157 * Sorts an array of floats and creates an integer array holding indices of sorted float values based on158 * pre-sort index positions.159 *160 * @return psIntArray*: Pointer to psIntArray of sorted indices.161 */162 153 163 154 psIntArray *psSortIndex( … … 177 168 178 169 if(outArray == NULL) { 179 p rintf("NULL output array n");170 psError(__func__, " : Line %d - Null output array\n", __LINE__); 180 171 return outArray; 181 172 } 182 173 183 174 if(inArray == NULL) { 184 p rintf("NULL input array\n");175 psError(__func__, " : Line %d - Null input array\n", __LINE__); 185 176 return outArray; 186 177 } … … 193 184 194 185 if(inN != outN) { 195 printf("Input and output array sizes are not equal"); 186 psError(__func__, " : Line %d - Input and output array sizes are not equal: in=%d out=%d\n", __LINE__, 187 inN, outN); 196 188 return outArray; 197 189 } -
trunk/psLib/src/collections/psSort.h
r437 r450 1 /** @file psSort.h 2 * 3 * @brief Sorts arrays 4 * 5 * The psSort functions use the qsort() stdlib function with a user-defined callback to sort an array of 6 * floats. The qsort function requires the starting point of the array, number of elements in the array, size 7 * of each element, and a pointer to a callback comparison function. Once called, qsort() will sort the array 8 * contents in ascending order according to the comparison function. The comparison function is called with 9 * two arguments that point to the objects being compared - in this case two floats. The comparison function 10 * must return an integer less than, equal to, or greater than zero if the first argument is considered to be 11 * respectively less than, equal to, or greater than the second. If two members compare as equal, their order 12 * in the sorted array is undefined. 13 * 14 * @author Ross Harman, MHPCC 15 * 16 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2004-04-19 20:10:46 $ 18 * 19 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 20 */ 21 22 #ifndef PSSORT_H 23 #define PSSORT_H 24 25 /******************************************************************************/ 26 /* DEFINE STATEMENTS */ 27 /******************************************************************************/ 28 29 // None 30 31 /******************************************************************************/ 32 /* TYPE DEFINITIONS */ 33 /******************************************************************************/ 34 35 // None 36 37 /*****************************************************************************/ 38 /* FUNCTION PROTOTYPES */ 39 /*****************************************************************************/ 40 41 /** Sort an array of floats. 42 * 43 * Sorts an array of floats in ascendin order with the qsort() stdlib function. 44 * 45 * @return psFloatArray*: Pointer to sorted psFloatArray. 46 */ 47 1 48 psFloatArray *psSort(psFloatArray *restrict out, const psFloatArray *restrict inArray); 49 50 /** Creates an array of indices based on sort odred of float array. 51 * 52 * Sorts an array of floats and creates an integer array holding indices of sorted float values based on 53 * pre-sort index positions. 54 * 55 * @return psIntArray*: Pointer to psIntArray of sorted indices. 56 */ 57 2 58 psIntArray *psSortIndex(psIntArray *restrict out, const psFloatArray *restrict inArray); 59 60 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
