Changeset 1920 for trunk/psLib/src/collections
- Timestamp:
- Sep 28, 2004, 1:26:49 PM (22 years ago)
- Location:
- trunk/psLib/src/collections
- Files:
-
- 4 edited
-
psArray.c (modified) (4 diffs)
-
psArray.h (modified) (3 diffs)
-
psVector.c (modified) (2 diffs)
-
psVector.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psArray.c
r1807 r1920 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-09- 14 20:01:52$11 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-09-28 23:26:48 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 21 21 /******************************************************************************/ 22 22 #include<stdlib.h> // for qsort, etc. 23 #include<string.h> 23 24 24 25 #include "psMemory.h" … … 58 59 } 59 60 60 psArray* psArrayRealloc( unsigned int nalloc, psArray* restrict in)61 psArray* psArrayRealloc(psArray* restrict in, unsigned int nalloc) 61 62 { 62 63 if (in == NULL) { … … 88 89 } 89 90 91 bool psArrayRemove(psArray* psArr, 92 psPTR data) 93 { 94 bool success = false; 95 96 if (psArr == NULL) { 97 return success; 98 } 99 100 int n = psArr->n; 101 psPTR* psArrData = psArr->data; 102 for (int i = n-1; i<0; i--) { 103 if (psArrData[i] == data) { 104 memmove(psArrData[i],psArrData[i+1],(n-i-1)*sizeof(psPTR)); 105 n--; 106 success = true; 107 } 108 } 109 psArr->n = n; // reset the array size to indicate the removed item(s) 110 111 return success; 112 } 113 90 114 void psArrayElementFree(psArray* restrict psArr) 91 115 { -
trunk/psLib/src/collections/psArray.h
r1471 r1920 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-0 8-11 19:47:31$14 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-09-28 23:26:48 $ 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> 22 24 23 25 #include "psType.h" … … 67 69 */ 68 70 psArray* psArrayRealloc( 69 unsigned int nalloc, ///< Total number of elements to make available. 70 psArray* restrict psArr ///< array to reallocate. 71 psArray* restrict psArr, ///< array to reallocate. 72 unsigned int nalloc ///< Total number of elements to make available. 73 ); 74 75 /** Remove an element from the array 76 * 77 * Finds and removes the specified data pointer from the list. 78 * 79 * @return bool: TRUE if the specified data pointer was found and removed, 80 * otherwise FALSE. 81 * 82 */ 83 bool psArrayRemove( 84 psArray* psArr, ///< array to operate on 85 psPTR data ///< the data pointer to remove from psArray 71 86 ); 72 87 -
trunk/psLib/src/collections/psVector.c
r1897 r1920 10 10 * @author Robert DeSonia, MHPCC 11 11 * 12 * @version $Revision: 1.2 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-09-2 5 02:06:12$12 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-09-28 23:26:48 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 64 64 } 65 65 66 psVector* psVectorRealloc( unsigned int nalloc, psVector* restrict in)66 psVector* psVectorRealloc(psVector* restrict in, unsigned int nalloc) 67 67 { 68 68 int elementSize = 0; -
trunk/psLib/src/collections/psVector.h
r1897 r1920 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-09-2 5 02:06:12$14 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-09-28 23:26:48 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 83 83 */ 84 84 psVector* psVectorRealloc( 85 unsigned int nalloc, ///< Total number of elements to make available.86 psVector* restrict psVec ///< Vector to reallocate.85 psVector* restrict psVec, ///< Vector to reallocate. 86 unsigned int nalloc ///< Total number of elements to make available. 87 87 ); 88 88
Note:
See TracChangeset
for help on using the changeset viewer.
