Changeset 1440 for trunk/psLib/src/collections/psHash.c
- Timestamp:
- Aug 9, 2004, 1:34:58 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
r1420 r1440 11 11 * @author George Gusciora, MHPCC 12 12 * 13 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-08-09 2 0:29:43$13 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-08-09 23:34:57 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 26 26 #include "psAbort.h" 27 27 28 static psHashBucket *hashBucketAlloc(const char *key, void *data, psHashBucket* next);29 static void hashBucketFree(psHashBucket * bucket);30 static void *doHashWork(psHash * table, const char *key, void *data, bool remove28 static psHashBucket* hashBucketAlloc(const char *key, void *data, psHashBucket* next); 29 static void hashBucketFree(psHashBucket* bucket); 30 static void *doHashWork(psHash* table, const char *key, void *data, bool remove 31 31 ); 32 static void hashFree(psHash * table);32 static void hashFree(psHash* table); 33 33 34 34 /****************************************************************************** … … 40 40 The linked list 41 41 *****************************************************************************/ 42 psList *psHashKeyList(psHash* table)42 psList* psHashKeyList(psHash* table) 43 43 { 44 44 int i = 0; // Loop index variable 45 psList *myLinkList = NULL; // The output data structure46 psHashBucket *ptr = NULL; // Used to step thru linked list.45 psList* myLinkList = NULL; // The output data structure 46 psHashBucket* ptr = NULL; // Used to step thru linked list. 47 47 48 48 if (table == NULL) { … … 81 81 the new hash bucket. 82 82 *****************************************************************************/ 83 static psHashBucket *hashBucketAlloc(const char *key, void *data, psHashBucket* next)83 static psHashBucket* hashBucketAlloc(const char *key, void *data, psHashBucket* next) 84 84 { 85 85 if (key == NULL) { … … 87 87 } 88 88 // Allocate memory for the new hash bucket. 89 psHashBucket *bucket = psAlloc(sizeof(psHashBucket));89 psHashBucket* bucket = psAlloc(sizeof(psHashBucket)); 90 90 91 91 p_psMemSetDeallocator(bucket, (psFreeFcn) hashBucketFree); … … 114 114 NONE 115 115 *****************************************************************************/ 116 static void hashBucketFree(psHashBucket * bucket)116 static void hashBucketFree(psHashBucket* bucket) 117 117 { 118 118 if (bucket == NULL) { … … 133 133 The new hash table. 134 134 *****************************************************************************/ 135 psHash *psHashAlloc(int nbucket) // initial number of buckets135 psHash* psHashAlloc(int nbucket) // initial number of buckets 136 136 { 137 137 int i = 0; // loop index variable 138 138 139 139 // Create the new hash table. 140 psHash *table = psAlloc(sizeof(psHash));140 psHash* table = psAlloc(sizeof(psHash)); 141 141 142 142 p_psMemSetDeallocator(table, (psFreeFcn) hashFree); 143 143 144 144 // Allocate memory for the buckets. 145 table->buckets = psAlloc(nbucket * sizeof(psHashBucket *));145 table->buckets = psAlloc(nbucket * sizeof(psHashBucket* )); 146 146 table->nbucket = nbucket; 147 147 … … 168 168 NONE 169 169 *****************************************************************************/ 170 static void hashFree(psHash * table)170 static void hashFree(psHash* table) 171 171 { 172 172 int i = 0; // Loop index variable. … … 210 210 there is little common code between those functions. 211 211 *****************************************************************************/ 212 static void *doHashWork(psHash * table, const char *key, void *data, bool remove212 static void *doHashWork(psHash* table, const char *key, void *data, bool remove 213 213 ) 214 214 { … … 217 217 // "hashed" from the key. 218 218 char *tmpchar = NULL; // Used in computing the hash function. 219 psHashBucket *ptr = NULL; // Used to retrieve the hash bucket.220 psHashBucket *optr = NULL; // "original pointer": used to step219 psHashBucket* ptr = NULL; // Used to retrieve the hash bucket. 220 psHashBucket* optr = NULL; // "original pointer": used to step 221 221 222 222 // thru the linked list for a bucket. … … 338 338 boolean value defining success or failure 339 339 *****************************************************************************/ 340 bool psHashAdd(psHash * table, const char *key, void *data)340 bool psHashAdd(psHash* table, const char *key, void *data) 341 341 { 342 342 if (table == NULL) { … … 364 364 The data associated with that key. 365 365 *****************************************************************************/ 366 void *psHashLookup(psHash * table, // table to lookup key in366 void *psHashLookup(psHash* table, // table to lookup key in 367 367 const char *key) // key to lookup 368 368 { … … 387 387 boolean value defining success or failure 388 388 *****************************************************************************/ 389 bool psHashRemove(psHash * table, const char *key)389 bool psHashRemove(psHash* table, const char *key) 390 390 { 391 391 void *data = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.
