Changeset 2204 for trunk/psLib/src/collections/psHash.c
- Timestamp:
- Oct 26, 2004, 2:57:34 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/collections/psHash.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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) {
Note:
See TracChangeset
for help on using the changeset viewer.
