Changeset 4135
- Timestamp:
- Jun 7, 2005, 12:36:48 PM (21 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 4 edited
-
collections/psHash.c (modified) (5 diffs)
-
collections/psHash.h (modified) (5 diffs)
-
types/psHash.c (modified) (5 diffs)
-
types/psHash.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psHash.c
r3769 r4135 9 9 * 10 10 * @author Robert Lupton, Princeton University 11 * @author George Gusciora, MHPCC12 11 * @author Robert DeSonia, MHPCC 12 * @author GLG, MHPCC 13 13 * 14 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-0 4-26 19:53:30$14 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-06-07 22:36:48 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 346 346 psPtr data) 347 347 { 348 if (table == NULL) { 349 psError(PS_ERR_BAD_PARAMETER_NULL, true, 350 PS_ERRORTEXT_psHash_TABLE_NULL); 351 return false; 352 } 353 if (key == NULL) { 354 psError(PS_ERR_BAD_PARAMETER_NULL, true, 355 PS_ERRORTEXT_psHash_KEY_NULL); 356 return false; 357 } 358 if (data == NULL) { 359 psError(PS_ERR_BAD_PARAMETER_NULL, true, 360 PS_ERRORTEXT_psHash_DATA_NULL); 361 return false; 362 } 348 PS_ASSERT_PTR_NON_NULL(table, false); 349 PS_ASSERT_PTR_NON_NULL(key, false); 350 PS_ASSERT_PTR_NON_NULL(data, false); 363 351 364 352 return (doHashWork(table, key, data, false) != NULL); … … 379 367 const char *key) // key to lookup 380 368 { 381 if (table == NULL) { 382 psError(PS_ERR_BAD_PARAMETER_NULL, true, 383 PS_ERRORTEXT_psHash_TABLE_NULL); 384 return NULL; 385 } 386 if (key == NULL) { 387 psError(PS_ERR_BAD_PARAMETER_NULL, true, 388 PS_ERRORTEXT_psHash_KEY_NULL); 389 return NULL; 390 } 369 PS_ASSERT_PTR_NON_NULL(table, false); 370 PS_ASSERT_PTR_NON_NULL(key, false); 391 371 392 372 return doHashWork(table, key, NULL, false); … … 408 388 psBool retVal = false; 409 389 410 if (table == NULL) { 411 psError(PS_ERR_BAD_PARAMETER_NULL, true, 412 PS_ERRORTEXT_psHash_TABLE_NULL); 413 return false; 414 } 415 if (key == NULL) { 416 psError(PS_ERR_BAD_PARAMETER_NULL, true, 417 PS_ERRORTEXT_psHash_KEY_NULL); 418 return false; 419 } 390 PS_ASSERT_PTR_NON_NULL(table, false); 391 PS_ASSERT_PTR_NON_NULL(key, false); 420 392 421 393 data = doHashWork(table, key, NULL, true); … … 431 403 psArray* psHashToArray(psHash* table) 432 404 { 433 434 if (table == NULL) { 435 psError(PS_ERR_BAD_PARAMETER_NULL, true, 436 PS_ERRORTEXT_psHash_TABLE_NULL); 437 return NULL; 438 } 405 PS_ASSERT_PTR_NON_NULL(table, NULL); 439 406 440 407 // first, let's just count the number of data elements to know what size -
trunk/psLib/src/collections/psHash.h
r3264 r4135 1 2 1 /** @file psHash.h 3 2 * @brief Contains support for basic hashing functions. … … 9 8 * 10 9 * @author Robert Lupton, Princeton University 11 * @author George Gusciora, MHPCC12 10 * @author Robert DeSonia, MHPCC 11 * @author GLG, MHPCC 13 12 * 14 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-0 2-17 19:26:23$13 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-06-07 22:36:48 $ 16 15 * 17 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 29 28 typedef struct psHashBucket 30 29 { 31 char *key; ///< key for this item of data32 psPtr data; ///< the data itself33 struct psHashBucket* next; ///< list of other possible keys30 char *key; ///< The key for this item of data. 31 psPtr data; ///< The data itself. 32 struct psHashBucket* next; ///< The list of other possible keys. 34 33 } 35 34 psHashBucket; … … 52 51 /// Insert entry into table. 53 52 psBool psHashAdd( 54 psHash* table, ///< table to insert in55 const char *key, ///< key to use56 psPtr data ///< data to insert53 psHash* table, ///< The table to insert in. 54 const char *key, ///< The key to use. 55 psPtr data ///< The data to insert. 57 56 ); 58 57 59 58 /// Lookup key in table. 60 59 psPtr psHashLookup( 61 psHash* table, ///< table to lookup key in62 const char *key ///< key to lookup60 psHash* table, ///< The table to lookup key in. 61 const char *key ///< The key to lookup. 63 62 ); 64 63 65 64 /// Remove key from table. 66 65 psBool psHashRemove( 67 psHash* table, ///< table to lookup key in68 const char *key ///< key to lookup66 psHash* table, ///< The table to lookup key in. 67 const char *key ///< The key to lookup. 69 68 ); 70 69 71 70 /// List all keys in table. 72 71 psList* psHashKeyList( 73 psHash* table ///< table to list keys from.72 psHash* table ///< The table to list keys from.. 74 73 ); 75 74 … … 79 78 */ 80 79 psArray* psHashToArray( 81 psHash* table ///< table to convert to psArray80 psHash* table ///< The table to convert to psArray. 82 81 ); 83 82 -
trunk/psLib/src/types/psHash.c
r3769 r4135 9 9 * 10 10 * @author Robert Lupton, Princeton University 11 * @author George Gusciora, MHPCC12 11 * @author Robert DeSonia, MHPCC 12 * @author GLG, MHPCC 13 13 * 14 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-0 4-26 19:53:30$14 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-06-07 22:36:48 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 346 346 psPtr data) 347 347 { 348 if (table == NULL) { 349 psError(PS_ERR_BAD_PARAMETER_NULL, true, 350 PS_ERRORTEXT_psHash_TABLE_NULL); 351 return false; 352 } 353 if (key == NULL) { 354 psError(PS_ERR_BAD_PARAMETER_NULL, true, 355 PS_ERRORTEXT_psHash_KEY_NULL); 356 return false; 357 } 358 if (data == NULL) { 359 psError(PS_ERR_BAD_PARAMETER_NULL, true, 360 PS_ERRORTEXT_psHash_DATA_NULL); 361 return false; 362 } 348 PS_ASSERT_PTR_NON_NULL(table, false); 349 PS_ASSERT_PTR_NON_NULL(key, false); 350 PS_ASSERT_PTR_NON_NULL(data, false); 363 351 364 352 return (doHashWork(table, key, data, false) != NULL); … … 379 367 const char *key) // key to lookup 380 368 { 381 if (table == NULL) { 382 psError(PS_ERR_BAD_PARAMETER_NULL, true, 383 PS_ERRORTEXT_psHash_TABLE_NULL); 384 return NULL; 385 } 386 if (key == NULL) { 387 psError(PS_ERR_BAD_PARAMETER_NULL, true, 388 PS_ERRORTEXT_psHash_KEY_NULL); 389 return NULL; 390 } 369 PS_ASSERT_PTR_NON_NULL(table, false); 370 PS_ASSERT_PTR_NON_NULL(key, false); 391 371 392 372 return doHashWork(table, key, NULL, false); … … 408 388 psBool retVal = false; 409 389 410 if (table == NULL) { 411 psError(PS_ERR_BAD_PARAMETER_NULL, true, 412 PS_ERRORTEXT_psHash_TABLE_NULL); 413 return false; 414 } 415 if (key == NULL) { 416 psError(PS_ERR_BAD_PARAMETER_NULL, true, 417 PS_ERRORTEXT_psHash_KEY_NULL); 418 return false; 419 } 390 PS_ASSERT_PTR_NON_NULL(table, false); 391 PS_ASSERT_PTR_NON_NULL(key, false); 420 392 421 393 data = doHashWork(table, key, NULL, true); … … 431 403 psArray* psHashToArray(psHash* table) 432 404 { 433 434 if (table == NULL) { 435 psError(PS_ERR_BAD_PARAMETER_NULL, true, 436 PS_ERRORTEXT_psHash_TABLE_NULL); 437 return NULL; 438 } 405 PS_ASSERT_PTR_NON_NULL(table, NULL); 439 406 440 407 // first, let's just count the number of data elements to know what size -
trunk/psLib/src/types/psHash.h
r3264 r4135 1 2 1 /** @file psHash.h 3 2 * @brief Contains support for basic hashing functions. … … 9 8 * 10 9 * @author Robert Lupton, Princeton University 11 * @author George Gusciora, MHPCC12 10 * @author Robert DeSonia, MHPCC 11 * @author GLG, MHPCC 13 12 * 14 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-0 2-17 19:26:23$13 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-06-07 22:36:48 $ 16 15 * 17 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 29 28 typedef struct psHashBucket 30 29 { 31 char *key; ///< key for this item of data32 psPtr data; ///< the data itself33 struct psHashBucket* next; ///< list of other possible keys30 char *key; ///< The key for this item of data. 31 psPtr data; ///< The data itself. 32 struct psHashBucket* next; ///< The list of other possible keys. 34 33 } 35 34 psHashBucket; … … 52 51 /// Insert entry into table. 53 52 psBool psHashAdd( 54 psHash* table, ///< table to insert in55 const char *key, ///< key to use56 psPtr data ///< data to insert53 psHash* table, ///< The table to insert in. 54 const char *key, ///< The key to use. 55 psPtr data ///< The data to insert. 57 56 ); 58 57 59 58 /// Lookup key in table. 60 59 psPtr psHashLookup( 61 psHash* table, ///< table to lookup key in62 const char *key ///< key to lookup60 psHash* table, ///< The table to lookup key in. 61 const char *key ///< The key to lookup. 63 62 ); 64 63 65 64 /// Remove key from table. 66 65 psBool psHashRemove( 67 psHash* table, ///< table to lookup key in68 const char *key ///< key to lookup66 psHash* table, ///< The table to lookup key in. 67 const char *key ///< The key to lookup. 69 68 ); 70 69 71 70 /// List all keys in table. 72 71 psList* psHashKeyList( 73 psHash* table ///< table to list keys from.72 psHash* table ///< The table to list keys from.. 74 73 ); 75 74 … … 79 78 */ 80 79 psArray* psHashToArray( 81 psHash* table ///< table to convert to psArray80 psHash* table ///< The table to convert to psArray. 82 81 ); 83 82
Note:
See TracChangeset
for help on using the changeset viewer.
