Changeset 4352 for trunk/psLib/src/collections/psHash.c
- Timestamp:
- Jun 22, 2005, 1:48:39 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/collections/psHash.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psHash.c
r4343 r4352 12 12 * @author GLG, MHPCC 13 13 * 14 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-06-22 03:00:27$14 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-06-22 23:48:39 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 343 343 boolean value defining success or failure 344 344 *****************************************************************************/ 345 bool psHashAdd(psHash* table,345 bool psHashAdd(psHash* hash, 346 346 const char *key, 347 347 psPtr data) 348 348 { 349 PS_ASSERT_PTR_NON_NULL( table, false);349 PS_ASSERT_PTR_NON_NULL(hash, false); 350 350 PS_ASSERT_PTR_NON_NULL(key, false); 351 351 PS_ASSERT_PTR_NON_NULL(data, false); 352 352 353 return (doHashWork( table, key, data, false) != NULL);353 return (doHashWork(hash, key, data, false) != NULL); 354 354 } 355 355 … … 365 365 The data associated with that key. 366 366 *****************************************************************************/ 367 psPtr psHashLookup(const psHash* table, // tableto lookup key in367 psPtr psHashLookup(const psHash* hash, // hash to lookup key in 368 368 const char *key) // key to lookup 369 369 { 370 PS_ASSERT_PTR_NON_NULL( table, NULL);370 PS_ASSERT_PTR_NON_NULL(hash, NULL); 371 371 PS_ASSERT_PTR_NON_NULL(key, NULL); 372 372 373 return doHashWork((psPtr) table, key, NULL, false);373 return doHashWork((psPtr)hash, key, NULL, false); 374 374 } 375 375 … … 383 383 boolean value defining success or failure 384 384 *****************************************************************************/ 385 bool psHashRemove(psHash* table,385 bool psHashRemove(psHash* hash, 386 386 const char *key) 387 387 { … … 389 389 psBool retVal = false; 390 390 391 PS_ASSERT_PTR_NON_NULL( table, false);391 PS_ASSERT_PTR_NON_NULL(hash, false); 392 392 PS_ASSERT_PTR_NON_NULL(key, false); 393 393 394 data = doHashWork( table, key, NULL, true);394 data = doHashWork(hash, key, NULL, true); 395 395 if (data != NULL) { 396 396 retVal = true; … … 402 402 } 403 403 404 psArray* psHashToArray(const psHash* table)405 { 406 PS_ASSERT_PTR_NON_NULL( table, NULL);404 psArray* psHashToArray(const psHash* hash) 405 { 406 PS_ASSERT_PTR_NON_NULL(hash, NULL); 407 407 408 408 // first, let's just count the number of data elements to know what size 409 409 // psArray we need to allocate. 410 410 int nElements = 0; 411 int nbucket = table->nbucket;411 int nbucket = hash->nbucket; 412 412 for (int i = 0; i < nbucket; i++) { 413 psHashBucket* tmpBucket = table->buckets[i];413 psHashBucket* tmpBucket = hash->buckets[i]; 414 414 while (tmpBucket != NULL) { 415 415 nElements++; … … 421 421 result->n = nElements; 422 422 423 // now fill in the array with the hash table's data423 // now fill in the array with the hash hash's data 424 424 psPtr* data = result->data; 425 425 for (int i = 0; i < nbucket; i++) { 426 psHashBucket* tmpBucket = table->buckets[i];426 psHashBucket* tmpBucket = hash->buckets[i]; 427 427 while (tmpBucket != NULL) { 428 428 *(data++) = psMemIncrRefCounter(tmpBucket->data);
Note:
See TracChangeset
for help on using the changeset viewer.
