Changeset 4315 for trunk/psLib/src/types
- Timestamp:
- Jun 17, 2005, 4:30:50 PM (21 years ago)
- Location:
- trunk/psLib/src/types
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/types/psHash.c
r4136 r4315 12 12 * @author GLG, MHPCC 13 13 * 14 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-06- 07 22:37:52$14 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-06-18 02:30:49 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 43 43 The linked list 44 44 *****************************************************************************/ 45 psList* psHashKeyList( psHash* table)45 psList* psHashKeyList(const psHash* hash) 46 46 { 47 47 psS32 i = 0; // Loop index variable … … 49 49 psHashBucket* ptr = NULL; // Used to step thru linked list. 50 50 51 if ( table== NULL) {51 if (hash == NULL) { 52 52 return NULL; 53 53 } … … 57 57 // Loop through every bucket in the hash table. If that bucket is not 58 58 // NULL, then add the bucket's key to the linked list. 59 for (i = 0; i < table->nbucket; i++) {60 if ( table->buckets[i] != NULL) {59 for (i = 0; i < hash->nbucket; i++) { 60 if (hash->buckets[i] != NULL) { 61 61 // Since a bucket contains a linked list of keys/data, we must 62 62 // step trough each key in that linked list: 63 63 64 ptr = table->buckets[i];64 ptr = hash->buckets[i]; 65 65 while (ptr != NULL) { 66 66 psListAdd(myLinkList, PS_LIST_HEAD, ptr->key); … … 135 135 The new hash table. 136 136 *****************************************************************************/ 137 psHash* psHashAlloc( psS32 nbucket) // initial number of buckets137 psHash* psHashAlloc(long nalloc) // initial number of buckets 138 138 { 139 139 psS32 i = 0; // loop index variable … … 145 145 146 146 // Allocate memory for the buckets. 147 table->buckets = psAlloc(n bucket* sizeof(psHashBucket* ));148 table->nbucket = n bucket;149 150 psTrace("utils.hash", 1, "Creating %d-element hash table\n", n bucket);147 table->buckets = psAlloc(nalloc * sizeof(psHashBucket* )); 148 table->nbucket = nalloc; 149 150 psTrace("utils.hash", 1, "Creating %d-element hash table\n", nalloc); 151 151 152 152 // Initialize all buckets to NULL. 153 for (i = 0; i < n bucket; i++)153 for (i = 0; i < nalloc; i++) 154 154 { 155 155 table->buckets[i] = NULL; … … 383 383 boolean value defining success or failure 384 384 *****************************************************************************/ 385 psBool psHashRemove(psHash* table,386 const char *key)385 bool psHashRemove(psHash* table, 386 const char *key) 387 387 { 388 388 psPtr data = NULL; -
trunk/psLib/src/types/psHash.h
r4162 r4315 11 11 * @author GLG, MHPCC 12 12 * 13 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-06- 08 23:40:45$13 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-06-18 02:30:49 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 47 47 /// Allocate hash buckets in table. 48 48 psHash* psHashAlloc( 49 psS32 nbucket///< The number of buckets to allocate.49 long nalloc ///< The number of buckets to allocate. 50 50 ); 51 51 52 52 /// Insert entry into table. 53 53 psBool psHashAdd( 54 psHash* table, ///< The table to insert in.55 const char *key, ///< The key to use.56 psPtr data ///< The data to insert.54 psHash* table, ///< The table to insert in. 55 const char *key, ///< The key to use. 56 psPtr data ///< The data to insert. 57 57 ); 58 58 59 59 /// Lookup key in table. 60 60 psPtr psHashLookup( 61 psHash* table, ///< The table to lookup key in.62 const char *key ///< The key to lookup.61 psHash* table, ///< The table to lookup key in. 62 const char *key ///< The key to lookup. 63 63 ); 64 64 65 65 /// Remove key from table. 66 psBool psHashRemove(67 psHash* table, ///< The table to lookup key in.68 const char *key ///< The key to lookup.66 bool psHashRemove( 67 psHash* table, ///< The table to lookup key in. 68 const char *key ///< The key to lookup. 69 69 ); 70 70 71 71 /// List all keys in table. 72 72 psList* psHashKeyList( 73 psHash* table///< The table to list keys from..73 const psHash* hash ///< The table to list keys from.. 74 74 ); 75 75 … … 79 79 */ 80 80 psArray* psHashToArray( 81 psHash* table ///< The table to convert to psArray.81 psHash* table ///< The table to convert to psArray. 82 82 ); 83 83
Note:
See TracChangeset
for help on using the changeset viewer.
