Changeset 2204 for trunk/psLib/src/collections
- Timestamp:
- Oct 26, 2004, 2:57:34 PM (22 years ago)
- Location:
- trunk/psLib/src/collections
- Files:
-
- 16 edited
-
psArray.c (modified) (9 diffs)
-
psArray.h (modified) (6 diffs)
-
psBitSet.c (modified) (10 diffs)
-
psBitSet.h (modified) (7 diffs)
-
psCompare.c (modified) (1 diff)
-
psCompare.h (modified) (1 diff)
-
psHash.c (modified) (13 diffs)
-
psHash.h (modified) (5 diffs)
-
psList.c (modified) (16 diffs)
-
psList.h (modified) (11 diffs)
-
psMetadata.c (modified) (11 diffs)
-
psMetadata.h (modified) (10 diffs)
-
psMetadataIO.c (modified) (12 diffs)
-
psMetadataIO.h (modified) (3 diffs)
-
psVector.c (modified) (9 diffs)
-
psVector.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psArray.c
r1920 r2204 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $12 * @date $Date: 2004- 09-28 23:26:48$11 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-10-27 00:57:31 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 42 42 43 43 /*****************************************************************************/ 44 psArray* psArrayAlloc( unsigned intnalloc)44 psArray* psArrayAlloc(psU32 nalloc) 45 45 { 46 46 psArray* psArr = NULL; … … 54 54 55 55 // Create vector data array 56 psArr->data = psAlloc(nalloc * sizeof(psP TR));56 psArr->data = psAlloc(nalloc * sizeof(psPtr)); 57 57 58 58 return psArr; 59 59 } 60 60 61 psArray* psArrayRealloc(psArray* restrict in, unsigned intnalloc)61 psArray* psArrayRealloc(psArray* restrict in, psU32 nalloc) 62 62 { 63 63 if (in == NULL) { … … 65 65 } else if (in->nalloc != nalloc) { // No need to realloc to same size 66 66 if (nalloc < in->n) { 67 for ( inti = nalloc; i < in->n; i++) { // For reduction in vector size67 for (psS32 i = nalloc; i < in->n; i++) { // For reduction in vector size 68 68 psFree(in->data[i]); 69 69 } … … 71 71 } 72 72 // Realloc after decrementation to avoid accessing freed array elements 73 in->data = psRealloc(in->data, nalloc * sizeof(psP TR));73 in->data = psRealloc(in->data, nalloc * sizeof(psPtr)); 74 74 in->nalloc = nalloc; 75 75 } … … 89 89 } 90 90 91 bool psArrayRemove(psArray* psArr,92 psPTRdata)91 psBool psArrayRemove(psArray* psArr, 92 psPtr data) 93 93 { 94 bool success = false;94 psBool success = false; 95 95 96 96 if (psArr == NULL) { … … 98 98 } 99 99 100 intn = psArr->n;101 psP TR* psArrData = psArr->data;102 for ( inti = n-1; i<0; i--) {100 psS32 n = psArr->n; 101 psPtr* psArrData = psArr->data; 102 for (psS32 i = n-1; i<0; i--) { 103 103 if (psArrData[i] == data) { 104 memmove(psArrData[i],psArrData[i+1],(n-i-1)*sizeof(psP TR));104 memmove(psArrData[i],psArrData[i+1],(n-i-1)*sizeof(psPtr)); 105 105 n--; 106 106 success = true; … … 119 119 } 120 120 121 for ( inti = 0; i < psArr->n; i++) {121 for (psS32 i = 0; i < psArr->n; i++) { 122 122 psFree(psArr->data[i]); 123 123 psArr->data[i] = NULL; … … 131 131 } 132 132 133 qsort(in->data, in->n, sizeof(psP TR), (int (*)(const void *, const void*))compare);133 qsort(in->data, in->n, sizeof(psPtr), (int (*)(const void* , const void*))compare); 134 134 135 135 return in; -
trunk/psLib/src/collections/psArray.h
r1920 r2204 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $15 * @date $Date: 2004- 09-28 23:26:48$14 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-10-27 00:57:31 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 20 20 #ifndef PS_ARRAY_H 21 21 #define PS_ARRAY_H 22 23 #include<stdbool.h>24 22 25 23 #include "psType.h" … … 36 34 typedef struct 37 35 { 38 unsigned intnalloc; ///< Total number of elements available.39 unsigned intn; ///< Number of elements in use.40 psP TR* data; ///< An Array of pointer elements36 psU32 nalloc; ///< Total number of elements available. 37 psU32 n; ///< Number of elements in use. 38 psPtr* data; ///< An Array of pointer elements 41 39 } 42 40 psArray; … … 57 55 */ 58 56 psArray* psArrayAlloc( 59 unsigned intnalloc ///< Total number of elements to make available.57 psU32 nalloc ///< Total number of elements to make available. 60 58 ); 61 59 … … 70 68 psArray* psArrayRealloc( 71 69 psArray* restrict psArr, ///< array to reallocate. 72 unsigned intnalloc ///< Total number of elements to make available.70 psU32 nalloc ///< Total number of elements to make available. 73 71 ); 74 72 … … 81 79 * 82 80 */ 83 bool psArrayRemove(81 psBool psArrayRemove( 84 82 psArray* psArr, ///< array to operate on 85 psP TRdata ///< the data pointer to remove from psArray83 psPtr data ///< the data pointer to remove from psArray 86 84 ); 87 85 -
trunk/psLib/src/collections/psBitSet.c
r1842 r2204 11 11 * @author Robert DeSonia, MHPCC 12 12 * 13 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $14 * @date $Date: 2004- 09-21 23:17:52$13 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-10-27 00:57:31 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 21 21 #include <ctype.h> 22 22 #include <math.h> 23 #include <stdbool.h>24 23 25 24 #include "psBitSet.h" … … 48 47 * @return char*: Pointer to byte in which bit is contained. 49 48 */ 50 static char mask( intbit)49 static char mask(psS32 bit) 51 50 { 52 51 char mask = (char)0x01; … … 67 66 } 68 67 69 psBitSet* psBitSetAlloc( intn)70 { 71 intnumBytes = 0;68 psBitSet* psBitSetAlloc(psS32 n) 69 { 70 psS32 numBytes = 0; 72 71 psBitSet* newObj = NULL; 73 72 … … 95 94 96 95 psBitSet* psBitSetSet(psBitSet* inBitSet, 97 intbit)96 psS32 bit) 98 97 { 99 98 char *byte = NULL; … … 120 119 121 120 psBitSet* psBitSetClear(psBitSet* inBitSet, 122 intbit)121 psS32 bit) 123 122 { 124 123 char *byte = NULL; … … 144 143 } 145 144 146 bool psBitSetTest(const psBitSet* inBitSet,147 intbit)145 psBool psBitSetTest(const psBitSet* inBitSet, 146 psS32 bit) 148 147 { 149 148 char *byte = NULL; … … 173 172 const psBitSet* restrict inBitSet2) 174 173 { 175 inti = 0;176 intn = 0;174 psS32 i = 0; 175 psS32 n = 0; 177 176 char* outBits = NULL; 178 177 char* inBits1 = NULL; 179 178 char* inBits2 = NULL; 180 intop = UNKNOWN_OP;179 psS32 op = UNKNOWN_OP; 181 180 182 181 if (inBitSet1 == NULL) { … … 198 197 199 198 // make operator all caps 200 inttempStrLen = strlen(operator);199 psS32 tempStrLen = strlen(operator); 201 200 char* tempStr = psAlloc(tempStrLen+1); 202 201 203 for ( intlcv=0;lcv<tempStrLen;lcv++) {202 for (psS32 lcv=0;lcv<tempStrLen;lcv++) { 204 203 tempStr[lcv] = (char)toupper(operator[lcv]); 205 204 } … … 308 307 char *psBitSetToString(const psBitSet* restrict inBitSet) 309 308 { 310 inti = 0;311 intnumBits = inBitSet->n * 8;309 psS32 i = 0; 310 psS32 numBits = inBitSet->n * 8; 312 311 char *outString = psAlloc((size_t) numBits + 1); 313 312 -
trunk/psLib/src/collections/psBitSet.h
r1807 r2204 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $15 * @date $Date: 2004- 09-14 20:01:52$14 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-10-27 00:57:31 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 20 20 #ifndef PSBITSET_H 21 21 #define PSBITSET_H 22 23 #include "psType.h" 22 24 23 25 /// @addtogroup BitSet … … 35 37 typedef struct 36 38 { 37 intn; ///< Number of bytes in the array39 psS32 n; ///< Number of bytes in the array 38 40 char *bits; ///< Aray of bytes holding bits 39 41 } … … 54 56 /*@null@*/ 55 57 psBitSet* psBitSetAlloc( 56 intn ///< Number of bits in psBitSet array58 psS32 n ///< Number of bits in psBitSet array 57 59 ); 58 60 … … 68 70 /* @returned@ */ 69 71 psBitSet* restrict inMask, ///< Pointer to psBitSet to be set. 70 intbit ///< Bit to be set.72 psS32 bit ///< Bit to be set. 71 73 ); 72 74 … … 82 84 /* @returned@ */ 83 85 psBitSet* restrict inMask, ///< Pointer to psBitSet to be cleared. 84 intbit ///< Bit to be cleared.86 psS32 bit ///< Bit to be cleared. 85 87 ); 86 88 … … 95 97 */ 96 98 97 bool psBitSetTest(99 psBool psBitSetTest( 98 100 const psBitSet* restrict inMask, ///< Pointer psBitSet to be tested. 99 intbit ///< Bit to be tested.101 psS32 bit ///< Bit to be tested. 100 102 ); 101 103 -
trunk/psLib/src/collections/psCompare.c
r1407 r2204 7 7 * @author Robert Daniel DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $10 * @date $Date: 2004- 08-07 00:06:06$9 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-10-27 00:57:31 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 13 13 */ 14 14 15 #include "psType.h"16 15 #include "psCompare.h" 17 16 -
trunk/psLib/src/collections/psCompare.h
r1473 r2204 1 /** @file psCompare.h 2 * @brief Comparison functions for sorting routines 3 * 4 * @author Robert Daniel DeSonia, MHPCC 5 * 6 * @ingroup Compare 7 * 8 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-10-27 00:57:31 $ 10 * 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 12 */ 13 1 14 #if !defined(PS_COMPARE_H) 2 15 #define PS_COMPARE_H 3 16 4 /** @file psCompare.h 5 * @brief Comparison functions for sorting routines 6 * 7 * @author Robert Daniel DeSonia, MHPCC 8 * 9 * @ingroup Compare 10 * 11 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-08-11 19:58:11 $ 13 * 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 15 */ 17 #include "psType.h" 16 18 17 19 /** @addtogroup Compare -
trunk/psLib/src/collections/psHash.c
r1842 r2204 11 11 * @author George Gusciora, MHPCC 12 12 * 13 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $14 * @date $Date: 2004- 09-21 23:17:53$13 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-10-27 00:57:31 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 19 19 #include <stdio.h> 20 20 #include <string.h> 21 #include <stdbool.h>22 21 #include "psHash.h" 23 22 #include "psMemory.h" … … 29 28 #include "psCollectionsErrors.h" 30 29 31 static psHashBucket* hashBucketAlloc(const char *key, void *data, psHashBucket* next);30 static psHashBucket* hashBucketAlloc(const char *key, psPtr data, psHashBucket* next); 32 31 static void hashBucketFree(psHashBucket* bucket); 33 static void *doHashWork(psHash* table, const char *key, void *data, bool remove32 static psPtr doHashWork(psHash* table, const char *key, psPtr data, psBool remove 34 33 ); 35 34 static void hashFree(psHash* table); … … 45 44 psList* psHashKeyList(psHash* table) 46 45 { 47 inti = 0; // Loop index variable46 psS32 i = 0; // Loop index variable 48 47 psList* myLinkList = NULL; // The output data structure 49 48 psHashBucket* ptr = NULL; // Used to step thru linked list. … … 85 84 *****************************************************************************/ 86 85 static psHashBucket* hashBucketAlloc(const char *key, 87 void *data,86 psPtr data, 88 87 psHashBucket* next) 89 88 { … … 135 134 The new hash table. 136 135 *****************************************************************************/ 137 psHash* psHashAlloc( intnbucket) // initial number of buckets138 { 139 inti = 0; // loop index variable136 psHash* psHashAlloc(psS32 nbucket) // initial number of buckets 137 { 138 psS32 i = 0; // loop index variable 140 139 141 140 // Create the new hash table. … … 172 171 static void hashFree(psHash* table) 173 172 { 174 inti = 0; // Loop index variable.173 psS32 i = 0; // Loop index variable. 175 174 176 175 if (table == NULL) { … … 212 211 there is little common code between those functions. 213 212 *****************************************************************************/ 214 static void *doHashWork(psHash* table,213 static psPtr doHashWork(psHash* table, 215 214 const char *key, 216 void *data, bool remove215 psPtr data, psBool remove 217 216 ) 218 217 { 219 long inthash = 1; // This will contain an integer value218 psS64 hash = 1; // This will contain an integer value 220 219 221 220 // "hashed" from the key. … … 236 235 } 237 236 // NOTE: This is the originally supplied hash function. 238 // for ( inti = 0, len = strlen(key); i < len; i++) {237 // for (psS32 i = 0, len = strlen(key); i < len; i++) { 239 238 // hash = (hash << 1) ^ key[i]; 240 239 // } … … 273 272 // of removing an item from a single-linked list. 274 273 275 void *data = ptr->data;274 psPtr data = ptr->data; 276 275 277 276 optr->next = ptr->next; … … 344 343 boolean value defining success or failure 345 344 *****************************************************************************/ 346 bool psHashAdd(psHash* table,347 const char *key,348 void *data)345 psBool psHashAdd(psHash* table, 346 const char *key, 347 psPtr data) 349 348 { 350 349 if (table == NULL) { … … 380 379 The data associated with that key. 381 380 *****************************************************************************/ 382 void *psHashLookup(psHash* table, // table to lookup key in381 psPtr psHashLookup(psHash* table, // table to lookup key in 383 382 const char *key) // key to lookup 384 383 { … … 409 408 boolean value defining success or failure 410 409 *****************************************************************************/ 411 bool psHashRemove(psHash* table,412 const char *key)413 { 414 void *data = NULL;415 bool retVal = false;410 psBool psHashRemove(psHash* table, 411 const char *key) 412 { 413 psPtr data = NULL; 414 psBool retVal = false; 416 415 417 416 if (table == NULL) { -
trunk/psLib/src/collections/psHash.h
r1441 r2204 11 11 * @author George Gusciora, MHPCC 12 12 * 13 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $14 * @date $Date: 2004- 08-09 23:40:55$13 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-10-27 00:57:31 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 22 22 * \{ 23 23 */ 24 #include<stdbool.h>25 24 26 25 #include "psList.h" … … 30 29 { 31 30 char *key; ///< key for this item of data 32 void *data; ///< the data itself31 psPtr data; ///< the data itself 33 32 struct psHashBucket* next; ///< list of other possible keys 34 33 } … … 40 39 typedef struct psHash 41 40 { 42 intnbucket; ///< Number of buckets in hash table.41 psS32 nbucket; ///< Number of buckets in hash table. 43 42 psHashBucket* *buckets; ///< The bucket data. 44 43 } … … 46 45 47 46 /// Allocate hash buckets in table. 48 psHash* psHashAlloc( intnbucket ///< The number of buckets to allocate.47 psHash* psHashAlloc(psS32 nbucket ///< The number of buckets to allocate. 49 48 ); 50 49 51 50 /// Insert entry into table. 52 bool psHashAdd(psHash* table, ///< table to insert in53 const char *key, ///< key to use54 void *data ///< data to insert55 );51 psBool psHashAdd(psHash* table, ///< table to insert in 52 const char *key, ///< key to use 53 psPtr data ///< data to insert 54 ); 56 55 57 56 /// Lookup key in table. 58 void *psHashLookup(psHash* table, ///< table to lookup key in57 psPtr psHashLookup(psHash* table, ///< table to lookup key in 59 58 const char *key ///< key to lookup 60 59 ); 61 60 62 61 /// Remove key from table. 63 bool psHashRemove(psHash* table, ///< table to lookup key in64 const char *key ///< key to lookup65 );62 psBool psHashRemove(psHash* table, ///< table to lookup key in 63 const char *key ///< key to lookup 64 ); 66 65 67 66 /// List all keys in table. -
trunk/psLib/src/collections/psList.c
r1807 r2204 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $9 * @date $Date: 2004- 09-14 20:01:52$8 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-10-27 00:57:31 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 13 13 14 14 #include <stdlib.h> 15 #include <stdbool.h>16 15 #include <stdio.h> 17 16 #include <pthread.h> // we need a mutex to make this stuff thread safe. … … 26 25 #include "psCollectionsErrors.h" 27 26 28 #define ITER_INIT_HEAD (( void *)1) // next iteration should return head29 #define ITER_INIT_TAIL (( void *)2) // next iteration should return tail27 #define ITER_INIT_HEAD ((psPtr )1) // next iteration should return head 28 #define ITER_INIT_TAIL ((psPtr )2) // next iteration should return tail 30 29 31 30 // private functions. 32 31 static psListElem* listGetIterator(psList* list); 33 static intlistGetIteratorIndex(psList* list);34 static void listSetIterator(psList* list, int where, bool lockList);32 static psS32 listGetIteratorIndex(psList* list); 33 static void listSetIterator(psList* list, psS32 where, psBool lockList); 35 34 static void listFree(psList* list); 36 35 37 psList* psListAlloc( void *data)36 psList* psListAlloc(psPtr data) 38 37 { 39 38 psList* list = psAlloc(sizeof(psList)); … … 82 81 } 83 82 84 bool psListAdd(psList* list, int location, void *data)83 psBool psListAdd(psList* list, psS32 location, psPtr data) 85 84 { 86 85 psListElem* position; 87 86 psListElem* elem; 88 intcursorIndex = 0;87 psS32 cursorIndex = 0; 89 88 90 89 if (list == NULL) { … … 168 167 * Remove an element from a list 169 168 */ 170 bool psListRemove(psList* list, int location, void *data)169 psBool psListRemove(psList* list, psS32 location, psPtr data) 171 170 { 172 171 psListElem* elem = NULL; // element to remove 173 intcursorIndex = 0;172 psS32 cursorIndex = 0; 174 173 175 174 if (list == NULL) { … … 184 183 // search list for the data item. 185 184 186 inti = 0; // index185 psS32 i = 0; // index 187 186 188 187 for (psListElem* ptr = list->head; ptr != NULL; ptr = ptr->next) { … … 247 246 } 248 247 249 void psListSetIterator(psList* list, intwhere)248 void psListSetIterator(psList* list, psS32 where) 250 249 { 251 250 listSetIterator(list, where, true); 252 251 } 253 252 254 static void listSetIterator(psList* list, int where, bool lockList)253 static void listSetIterator(psList* list, psS32 where, psBool lockList) 255 254 { 256 255 psListElem* cursor; 257 intposition;256 psS32 position; 258 257 259 258 if (list == NULL) { … … 272 271 } 273 272 274 if (where >= ( int)list->size) {273 if (where >= (psS32)list->size) { 275 274 list->iter = NULL; 276 275 if (lockList) { … … 323 322 } 324 323 325 intposition = listGetIteratorIndex(list);324 psS32 position = listGetIteratorIndex(list); 326 325 327 326 if (where < position) { 328 intdiff = position - where;329 330 for ( intcount = 0; count < diff; count++) {327 psS32 diff = position - where; 328 329 for (psS32 count = 0; count < diff; count++) { 331 330 listSetIterator(list, PS_LIST_PREVIOUS, false); 332 331 } 333 332 } else { 334 intdiff = where - position;335 336 for ( intcount = 0; count < diff; count++) {333 psS32 diff = where - position; 334 335 for (psS32 count = 0; count < diff; count++) { 337 336 listSetIterator(list, PS_LIST_NEXT, false); 338 337 } … … 363 362 } 364 363 365 intlistGetIteratorIndex(psList* list)364 psS32 listGetIteratorIndex(psList* list) 366 365 { 367 366 if (list->iter == ITER_INIT_HEAD) { … … 374 373 } 375 374 376 void *psListGet(psList* list, intlocation)375 psPtr psListGet(psList* list, psS32 location) 377 376 { 378 377 psListElem* element; … … 391 390 * and now return the previous/next element of the list 392 391 */ 393 void *psListGetNext(psList* list)392 psPtr psListGetNext(psList* list) 394 393 { 395 394 return psListGet(list, PS_LIST_NEXT); 396 395 } 397 396 398 void *psListGetPrevious(psList* list)397 psPtr psListGetPrevious(psList* list) 399 398 { 400 399 return psListGet(list, PS_LIST_PREVIOUS); 401 400 } 402 401 403 void *psListGetCurrent(psList* list)402 psPtr psListGetCurrent(psList* list) 404 403 { 405 404 return psListGet(list, PS_LIST_CURRENT); … … 412 411 { 413 412 psListElem* ptr; 414 unsigned intn;413 psU32 n; 415 414 psArray* restrict arr; 416 415 … … 429 428 ptr = list->head; 430 429 n = list->size; 431 for ( inti = 0; i < n; i++) {430 for (psS32 i = 0; i < n; i++) { 432 431 arr->data[i] = psMemIncrRefCounter(ptr->data); 433 432 ptr = ptr->next; … … 439 438 psList* psArrayToList(psArray* arr) 440 439 { 441 unsigned intn;440 psU32 n; 442 441 psList* list; // list of elements 443 442 … … 448 447 list = psListAlloc(NULL); 449 448 n = arr->n; 450 for ( inti = 0; i < n; i++) {449 for (psS32 i = 0; i < n; i++) { 451 450 psListAdd(list, PS_LIST_TAIL, arr->data[i]); 452 451 } -
trunk/psLib/src/collections/psList.h
r1747 r2204 10 10 * @ingroup LinkedList 11 11 * 12 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $13 * @date $Date: 2004- 09-09 02:23:27$12 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-10-27 00:57:31 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 17 17 18 18 #include <pthread.h> // we need a mutex to make this stuff thread safe. 19 #include <stdbool.h> // we use the bool type.20 19 21 20 #include "psCompare.h" … … 46 45 struct psListElem* prev; ///< previous link in list 47 46 struct psListElem* next; ///< next link in list 48 void *data; ///< real data item47 psPtr data; ///< real data item 49 48 } 50 49 psListElem; … … 57 56 typedef struct 58 57 { 59 unsigned intsize; ///< number of elements on list58 psU32 size; ///< number of elements on list 60 59 psListElem* head; ///< first element on list (may be NULL) 61 60 psListElem* tail; ///< last element on list (may be NULL) 62 61 psListElem* iter; ///< iteration cursor 63 unsigned intiterIndex; ///< the numeric position of the iteration cursor in the list62 psU32 iterIndex; ///< the numeric position of the iteration cursor in the list 64 63 pthread_mutex_t lock; ///< mutex to lock a node during changes 65 64 } … … 71 70 */ 72 71 psList* psListAlloc( 73 void *data72 psPtr data 74 73 ///< initial data item; may be NULL if no an empty psList is desired 75 74 ) … … 81 80 * NULL, the return value will also be NULL. 82 81 */ 83 bool psListAdd(82 psBool psListAdd( 84 83 psList* restrict list, ///< list to add to (if NULL, nothing is done) 85 intlocation, ///< index, PS_LIST_HEAD, PS_LIST_TAIL, or numbered location.86 void *data ///< data item to add. If NULL, list is not modified.84 psS32 location, ///< index, PS_LIST_HEAD, PS_LIST_TAIL, or numbered location. 85 psPtr data ///< data item to add. If NULL, list is not modified. 87 86 ); 88 87 89 88 /** Remove an item from a list. If location parameter is PS_LIST_UNKNOWN, 90 89 * 91 * @return bool TRUE if element is successfully removed, otherwise FALSE.90 * @return psBool TRUE if element is successfully removed, otherwise FALSE. 92 91 */ 93 bool psListRemove(92 psBool psListRemove( 94 93 psList* restrict list, 95 94 ///< list to remove element from 96 intlocation,95 psS32 location, 97 96 ///< index of item, or PS_LIST_UNKNOWN, PS_LIST_NEXT, PS_LIST_PREV, or numbered location. 98 void *data97 psPtr data 99 98 ///< if location is PS_LIST_UNKNOWN, data item to find and remove, otherwise this is ignored. 100 99 ); … … 102 101 /** Retrieve an item from a list. 103 102 * 104 * @return void*the item corresponding to the location parameter. If103 * @return psPtr the item corresponding to the location parameter. If 105 104 * location is invalid (e.g., a numbered index greater 106 105 * than the list size or if the list is empty), a 107 106 * NULL is returned. 108 107 */ 109 void *psListGet(108 psPtr psListGet( 110 109 psList* restrict list, ///< list to retrieve element from 111 intlocation ///< index number, or PS_LIST_NEXT, PS_LIST_PREV, PS_LIST_UNKNOWN110 psS32 location ///< index number, or PS_LIST_NEXT, PS_LIST_PREV, PS_LIST_UNKNOWN 112 111 ); 113 112 … … 118 117 void psListSetIterator( 119 118 psList* restrict list, ///< list to retrieve element from 120 intlocation ///< index number, PS_LIST_HEAD, or PS_LIST_TAIL119 psS32 location ///< index number, PS_LIST_HEAD, or PS_LIST_TAIL 121 120 ); 122 121 … … 124 123 * the next list position. 125 124 * 126 * @return void*the data item next on the list or NULL if the iterator125 * @return psPtr the data item next on the list or NULL if the iterator 127 126 * is already pointing to the last element or the list 128 127 * parameter was NULL. 129 128 */ 130 void *psListGetNext(129 psPtr psListGetNext( 131 130 psList* restrict list ///< list to retrieve element from 132 131 ); … … 135 134 * not move the iterator location. 136 135 * 137 * @return void*the data item cooresponding to current iterator136 * @return psPtr the data item cooresponding to current iterator 138 137 * cursor position of the list, or NULL if either the 139 138 * iterator is not valid or list parameter was NULL. 140 139 */ 141 void *psListGetCurrent(140 psPtr psListGetCurrent( 142 141 psList* restrict list ///< list to retrieve element from 143 142 ); … … 146 145 * iterator to the previous list position. 147 146 * 148 * @return void*the data item previous on the list or NULL if the iterator147 * @return psPtr the data item previous on the list or NULL if the iterator 149 148 * is already pointing to the first element or the list 150 149 * parameter was NULL. 151 150 */ 152 void *psListGetPrevious(151 psPtr psListGetPrevious( 153 152 psList* restrict list ///< list to retrieve element from 154 153 ); -
trunk/psLib/src/collections/psMetadata.c
r2040 r2204 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.3 4$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-10- 09 03:05:53$14 * @version $Revision: 1.35 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-10-27 00:57:30 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 59 59 /*****************************************************************************/ 60 60 61 static intmetadataId = 0;61 static psS32 metadataId = 0; 62 62 63 63 /*****************************************************************************/ … … 143 143 144 144 // Set metadata item unique id 145 *( int*)(&metadataItem->id) = ++metadataId;145 *(psS32 *)(&metadataItem->id) = ++metadataId; 146 146 147 147 // Set metadata item type … … 154 154 break; 155 155 case PS_META_BOOL: 156 metadataItem->data.B = ( bool)va_arg(argPtr, int);156 metadataItem->data.B = (psBool)va_arg(argPtr, psS32); 157 157 break; 158 158 case PS_META_S32: … … 215 215 } 216 216 217 bool psMetadataAddItem( psMetadata *restrict md, psMetadataItem *restrict metadataItem, intlocation )217 psBool psMetadataAddItem( psMetadata *restrict md, psMetadataItem *restrict metadataItem, psS32 location ) 218 218 { 219 219 char * key = NULL; … … 337 337 } 338 338 339 bool psMetadataAdd(psMetadata* restrict md, intwhere, const char *name, psMetadataType type,340 const char *comment, ...)339 psBool psMetadataAdd(psMetadata* restrict md, psS32 where, const char *name, psMetadataType type, 340 const char *comment, ...) 341 341 { 342 342 va_list argPtr; … … 359 359 } 360 360 361 bool psMetadataRemove(psMetadata* restrict md, intwhere, const char *restrict key)362 { 363 intnumChildren = 0;361 psBool psMetadataRemove(psMetadata* restrict md, psS32 where, const char *restrict key) 362 { 363 psS32 numChildren = 0; 364 364 psList* mdList = NULL; 365 365 psHash* mdTable = NULL; … … 471 471 } 472 472 473 psMetadataItem* psMetadataGet(psMetadata* restrict md, intwhere)473 psMetadataItem* psMetadataGet(psMetadata* restrict md, psS32 where) 474 474 { 475 475 psList* mdList = NULL; … … 497 497 } 498 498 499 bool psMetadataSetIterator(psMetadata* restrict md, intwhere)499 psBool psMetadataSetIterator(psMetadata* restrict md, psS32 where) 500 500 { 501 501 psList* mdList = NULL; … … 517 517 } 518 518 519 psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, intwhich)519 psMetadataItem* psMetadataGetNext(psMetadata* restrict md, const char *restrict match, psS32 which) 520 520 { 521 521 psList* mdList = NULL; … … 553 553 } 554 554 555 psMetadataItem* psMetadataGetPrevious(psMetadata* restrict md, const char *restrict match, intwhich)555 psMetadataItem* psMetadataGetPrevious(psMetadata* restrict md, const char *restrict match, psS32 which) 556 556 { 557 557 psList* mdList = NULL; -
trunk/psLib/src/collections/psMetadata.h
r1970 r2204 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.2 3$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-10- 06 01:06:27$13 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-10-27 00:57:30 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 38 38 PS_META_F32, ///< Single-precision float data. 39 39 PS_META_F64, ///< Double-precision float data. 40 PS_META_STR, ///< String data (Stored in as void *).41 PS_META_VEC, ///< Vector data (Stored in as void *).42 PS_META_IMG, ///< Image data (Stored in as void *).43 PS_META_JPEG, ///< JPEG data (Stored in as void *).44 PS_META_PNG, ///< PNG data (Stored in as void *).45 PS_META_ASTROM, ///< Astrometric coefficients (Stored in as void *).46 PS_META_UNKNOWN, ///< Other data (Stored in as void *).40 PS_META_STR, ///< String data (Stored in as psPtr ). 41 PS_META_VEC, ///< Vector data (Stored in as psPtr ). 42 PS_META_IMG, ///< Image data (Stored in as psPtr ). 43 PS_META_JPEG, ///< JPEG data (Stored in as psPtr ). 44 PS_META_PNG, ///< PNG data (Stored in as psPtr ). 45 PS_META_ASTROM, ///< Astrometric coefficients (Stored in as psPtr ). 46 PS_META_UNKNOWN, ///< Other data (Stored in as psPtr ). 47 47 PS_META_NTYPE ///< Number of types. Must be last. 48 48 } psMetadataType; … … 55 55 typedef struct psMetadataItem 56 56 { 57 const intid; ///< Unique ID for metadata item.57 const psS32 id; ///< Unique ID for metadata item. 58 58 char *restrict name; ///< Name of metadata item. 59 59 psMetadataType type; ///< Type of metadata item. 60 60 union { 61 bool B; ///< boolean data61 psBool B; ///< boolean data 62 62 psS32 S32; ///< Signed 32-bit integer data. 63 63 psF32 F32; ///< Single-precision float data. 64 64 psF64 F64; ///< Double-precision float data. 65 psP TRV; ///< Pointer to other type of data.65 psPtr V; ///< Pointer to other type of data. 66 66 } data; ///< Union for data types. 67 67 char *comment; ///< Optional comment ("", not NULL). … … 144 144 * @return bool: True for success, false for failure. 145 145 */ 146 bool psMetadataAddItem(146 psBool psMetadataAddItem( 147 147 psMetadata* restrict md, ///< Metadata collection to insert metadat item. 148 148 psMetadataItem* restrict item, ///< Metadata item to be added. 149 intlocation ///< Location to be added.149 psS32 location ///< Location to be added. 150 150 ); 151 151 … … 156 156 * @return bool: True for success, false for failure. 157 157 */ 158 bool psMetadataAdd(159 psMetadata* restrict md, ///< Metadata collection to insert metadat item. 160 intwhere, ///< Location to be added.158 psBool psMetadataAdd( 159 psMetadata* restrict md, ///< Metadata collection to insert metadat item. 160 psS32 where, ///< Location to be added. 161 161 const char *name, ///< Name of metadata item. 162 162 psMetadataType type, ///< Type of metadata item. … … 175 175 * @return bool: True for success, false for failure. 176 176 */ 177 bool psMetadataRemove(178 psMetadata* restrict md, ///< Metadata collection to insert metadat item. 179 intwhere, ///< Location to be removed.177 psBool psMetadataRemove( 178 psMetadata* restrict md, ///< Metadata collection to insert metadat item. 179 psS32 where, ///< Location to be removed. 180 180 const char *restrict key ///< Name of metadata key. 181 181 ); … … 203 203 psMetadataItem* psMetadataGet( 204 204 psMetadata* restrict md, ///< Metadata collection to insert metadat item. 205 intwhere ///< Location to be retrieved.205 psS32 where ///< Location to be retrieved. 206 206 ); 207 207 … … 213 213 * @return void: void. 214 214 */ 215 bool psMetadataSetIterator(215 psBool psMetadataSetIterator( 216 216 psMetadata* restrict md, ///< Metadata collection to iterate. 217 intwhere ///< Location of iterator.217 psS32 where ///< Location of iterator. 218 218 ); 219 219 … … 227 227 psMetadata* restrict md, ///< Metadata collection to iterate. 228 228 const char *restrict match, ///< Beginning of key name. 229 intwhich ///< Iterator to be used.229 psS32 which ///< Iterator to be used. 230 230 ); 231 231 … … 239 239 psMetadata* restrict md, ///< Metadata collection to iterate. 240 240 const char *restrict match, ///< Beginning of key name. 241 intwhich ///< Iterator to be used.241 psS32 which ///< Iterator to be used. 242 242 ); 243 243 -
trunk/psLib/src/collections/psMetadataIO.c
r2014 r2204 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-10- 08 00:43:12$11 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-10-27 00:57:30 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 104 104 /** Determines if a line is blank (whitespace only) or a commentline. It returns true if so. The input string 105 105 * must be null terminated. */ 106 bool ignoreLine(char *inString)106 psBool ignoreLine(char *inString) 107 107 { 108 108 while(*inString!='\0' && *inString!='#') { … … 119 119 /** Removes leading and trailing whitespace and # characters from a string. The cleaned string is a new null 120 120 * terminated copy of the original input string. */ 121 char *cleanString(char *inString, intsLen)121 char *cleanString(char *inString, psS32 sLen) 122 122 { 123 123 char *ptrB = NULL; … … 149 149 150 150 /** Count repeat occurances of a single character within a line. The input string must be null terminated. */ 151 intrepeatedChars(char *inString, char ch)152 { 153 intcount = 0;151 psS32 repeatedChars(char *inString, char ch) 152 { 153 psS32 count = 0; 154 154 155 155 … … 166 166 /** Returns cleaned token based on delimiter, but not including delimiter. Also changes the pointer location 167 167 * the beginning of the string. Tokens are newly allocated null terminated strings. */ 168 char* getToken(char **inString, char *delimiter, int*status)168 char* getToken(char **inString, char *delimiter, psS32 *status) 169 169 { 170 170 char *cleanToken = NULL; 171 intsLen = 0;171 psS32 sLen = 0; 172 172 173 173 … … 195 195 /** Returns single parsed value as a double precision number. The input string must be cleaned and null 196 196 * terminated. */ 197 double parseValue(char *inString, int*status)197 double parseValue(char *inString, psS32 *status) 198 198 { 199 199 char *end = NULL; … … 212 212 213 213 /** Returns true or false. 'T', 't', '1', 'F', 'f', and '0' are acceptable, parsable variations. */ 214 bool parseBool(char *inString, int*status)215 { 216 bool value = false;214 psBool parseBool(char *inString, psS32 *status) 215 { 216 psBool value = false; 217 217 218 218 … … 229 229 230 230 /** Returns parsed vector filled with with data. The input string must be null terminated. */ 231 psVector* parseVector(char *inString, psElemType elemType, int*status)231 psVector* parseVector(char *inString, psElemType elemType, psS32 *status) 232 232 { 233 233 char *end = NULL; 234 234 char *saveValue = NULL; 235 inti = 0;236 intnumValues = 0;235 psS32 i = 0; 236 psS32 numValues = 0; 237 237 double value = 0.0; 238 238 psVector *vec = NULL; … … 341 341 342 342 343 psMetadata* psMetadataReadHeader(psMetadata* output, char *extName, intextNum, char *fileName)344 { 345 bool tempBool;346 bool success;343 psMetadata* psMetadataReadHeader(psMetadata* output, char *extName, psS32 extNum, char *fileName) 344 { 345 psBool tempBool; 346 psBool success; 347 347 char keyType; 348 348 char keyName[FITS_LINE_SIZE]; … … 350 350 char keyComment[FITS_LINE_SIZE]; 351 351 char fitsErr[MAX_STRING_LENGTH]; 352 inti;353 inthduType = 0;354 intstatus = 0;355 intnumKeys = 0;356 intkeyNum = 0;352 psS32 i; 353 psS32 hduType = 0; 354 psS32 status = 0; 355 psS32 numKeys = 0; 356 psS32 keyNum = 0; 357 357 psMetadataType metadataItemType; 358 358 fitsfile *fd = NULL; … … 449 449 450 450 451 int psMetadataParseConfig(psMetadata** md, char *fileName, bool overwrite)452 { 453 bool tempBool;451 psS32 psMetadataParseConfig(psMetadata** md, char *fileName, psBool overwrite) 452 { 453 psBool tempBool; 454 454 char *line = NULL; 455 455 char *strName = NULL; … … 458 458 char *strComment = NULL; 459 459 char *linePtr = NULL; 460 intstatus = 0;461 intlineCount = 0;462 intfailedLines = 0;460 psS32 status = 0; 461 psS32 lineCount = 0; 462 psS32 failedLines = 0; 463 463 psF64 tempDbl = 0.0; 464 464 psS32 tempInt = 0.0; -
trunk/psLib/src/collections/psMetadataIO.h
r1973 r2204 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-10- 06 01:17:39$11 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-10-27 00:57:30 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 50 50 psMetadata* output, ///< Resulting metadata from read. 51 51 char *extName, ///< File name extension string. 52 intextNum, ///< File name extension number. Starts at 1.52 psS32 extNum, ///< File name extension number. Starts at 1. 53 53 char *fileName ///< Name of file to read. 54 54 ); … … 58 58 * Loads pre-defined settings by parsing a configuration file into a psMetadata structure. 59 59 * 60 * @return int: Number of lines that failed to be read.60 * @return psS32 : Number of lines that failed to be read. 61 61 */ 62 intpsMetadataParseConfig(62 psS32 psMetadataParseConfig( 63 63 psMetadata** md, ///< Resulting metadata from read. 64 64 char *fileName, ///< Name of file to read. 65 bool overwrite ///< Allow overwrite of duplicate specifications.65 psBool overwrite ///< Allow overwrite of duplicate specifications. 66 66 ); 67 67 -
trunk/psLib/src/collections/psVector.c
r2006 r2204 10 10 * @author Robert DeSonia, MHPCC 11 11 * 12 * @version $Revision: 1.2 8$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-10- 07 19:51:30$12 * @version $Revision: 1.29 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-10-27 00:57:31 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 42 42 // FUNCTION IMPLEMENTATION - PUBLIC 43 43 44 psVector* psVectorAlloc( unsigned intnalloc, psElemType elemType)44 psVector* psVectorAlloc(psU32 nalloc, psElemType elemType) 45 45 { 46 46 psVector* psVec = NULL; 47 intelementSize = 0;47 psS32 elementSize = 0; 48 48 49 49 elementSize = PSELEMTYPE_SIZEOF(elemType); … … 64 64 } 65 65 66 psVector* psVectorRealloc(psVector* restrict in, unsigned intnalloc)67 { 68 intelementSize = 0;66 psVector* psVectorRealloc(psVector* restrict in, psU32 nalloc) 67 { 68 psS32 elementSize = 0; 69 69 psElemType elemType; 70 70 … … 88 88 } 89 89 90 psVector* psVectorRecycle(psVector* restrict in, unsigned intn, psElemType type)91 { 92 intbyteSize;90 psVector* psVectorRecycle(psVector* restrict in, psU32 n, psElemType type) 91 { 92 psS32 byteSize; 93 93 94 94 if (in == NULL) { … … 129 129 } 130 130 131 intnElements = in->n;131 psS32 nElements = in->n; 132 132 133 133 out = psVectorRecycle(out, nElements, type); … … 136 136 ps##INTYPE *inVec = in->data.INTYPE; \ 137 137 ps##OUTTYPE *outVec = out->data.OUTTYPE; \ 138 for ( intcol=0;col<nElements;col++) { \138 for (psS32 col=0;col<nElements;col++) { \ 139 139 *(outVec++) = *(inVec++); \ 140 140 } \ … … 225 225 psVector* psVectorSort(psVector* restrict outVector, const psVector* restrict inVector) 226 226 { 227 intN = 0;228 intelSize = 0;229 void *inVec = NULL;230 void *outVec = NULL;227 psS32 N = 0; 228 psS32 elSize = 0; 229 psPtr inVec = NULL; 230 psPtr outVec = NULL; 231 231 psElemType inType = 0; 232 232 … … 311 311 psVector* psVectorSortIndex(psVector* restrict outVector, const psVector* restrict inVector) 312 312 { 313 intN = 0;313 psS32 N = 0; 314 314 psVector* tmpVector = NULL; 315 315 psElemType inType = 0; … … 350 350 ps##TYPE* tmpVec = tmpVector->data.TYPE; \ 351 351 ps##TYPE diff; \ 352 for( inti=0; i<N; i++) { \353 for( intj=0; j<N; j++) { \352 for(psS32 i=0; i<N; i++) { \ 353 for(psS32 j=0; j<N; j++) { \ 354 354 diff = absfcn(tmpVec[i] - inVec[j]); \ 355 355 if(diff < maxError) { \ -
trunk/psLib/src/collections/psVector.h
r1982 r2204 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.2 4$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-10- 06 21:30:52$13 * @version $Revision: 1.25 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-10-27 00:57:31 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 33 33 { 34 34 psType type; ///< Type of data. 35 unsigned intnalloc; ///< Total number of elements available.36 unsigned intn; ///< Number of elements in use.35 psU32 nalloc; ///< Total number of elements available. 36 psU32 n; ///< Number of elements in use. 37 37 38 38 union { … … 49 49 psC32* C32; ///< Single-precision complex data. 50 50 psC64* C64; ///< Double-precision complex data. 51 psP TRV; ///< Pointer to data.51 psPtr V; ///< Pointer to data. 52 52 } data; ///< Union for data types. 53 53 } … … 69 69 */ 70 70 psVector* psVectorAlloc( 71 unsigned intnalloc, ///< Total number of elements to make available.71 psU32 nalloc, ///< Total number of elements to make available. 72 72 psElemType dataType ///< Type of data to be held by vector. 73 73 ); … … 84 84 psVector* psVectorRealloc( 85 85 psVector* restrict psVec, ///< Vector to reallocate. 86 unsigned intnalloc ///< Total number of elements to make available.86 psU32 nalloc ///< Total number of elements to make available. 87 87 ); 88 88 … … 101 101 ///< taken to preserve the values. 102 102 103 unsigned intnalloc, ///< Total number of elements to make available.103 psU32 nalloc, ///< Total number of elements to make available. 104 104 psElemType type ///< the datatype of the returned vector 105 105 );
Note:
See TracChangeset
for help on using the changeset viewer.
