Changeset 4457 for trunk/psLib/src/collections/psHash.c
- Timestamp:
- Jul 5, 2005, 5:04:35 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/collections/psHash.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psHash.c
r4392 r4457 12 12 * @author GLG, MHPCC 13 13 * 14 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-0 6-25 02:02:05 $14 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-07-06 03:04:35 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 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 < hash->n bucket; i++) {59 for (i = 0; i < hash->n; i++) { 60 60 if (hash->buckets[i] != NULL) { 61 61 // Since a bucket contains a linked list of keys/data, we must … … 128 128 129 129 /****************************************************************************** 130 psHashAlloc(n bucket): this procedure creates a new hash table with the130 psHashAlloc(n): this procedure creates a new hash table with the 131 131 specified number of buckets. 132 132 Inputs: 133 n bucket: initial number of buckets133 n: initial number of buckets 134 134 Return: 135 135 The new hash table. … … 146 146 // Allocate memory for the buckets. 147 147 table->buckets = psAlloc(nalloc * sizeof(psHashBucket* )); 148 table->n bucket= nalloc;148 table->n = nalloc; 149 149 150 150 psTrace("utils.hash", 1, "Creating %d-element hash table\n", nalloc); … … 179 179 // Loop through each bucket in the hash table. If that bucket is not 180 180 // NULL, then free the bucket via a function call to hashBucketFree(); 181 for (i = 0; i < table->n bucket; i++) {181 for (i = 0; i < table->n; i++) { 182 182 183 183 // A bucket is composed of a linked list of buckets. … … 238 238 // hash = (hash << 1) ^ key[i]; 239 239 // } 240 // hash &= (table->n bucket- 1);240 // hash &= (table->n - 1); 241 241 242 242 // This hash algorithm is from Sedgewick. NOTE: must reread to ensure that … … 244 244 tmpchar = (char *)key; 245 245 for (hash = 0; *tmpchar != '\0'; tmpchar++) { 246 hash = (64 * hash + *tmpchar) % (table->n bucket);246 hash = (64 * hash + *tmpchar) % (table->n); 247 247 } 248 248 249 249 // NOTE: This should not be necessary, but for now, I'm checking bounds 250 250 // anyway. 251 if ((hash < 0) || (hash >= table->n bucket)) {251 if ((hash < 0) || (hash >= table->n)) { 252 252 psError(PS_ERR_UNKNOWN, true, 253 253 "Internal hash function out of range (%d)", hash); … … 409 409 // psArray we need to allocate. 410 410 int nElements = 0; 411 int nbucket = hash->n bucket;411 int nbucket = hash->n; 412 412 for (int i = 0; i < nbucket; i++) { 413 413 psHashBucket* tmpBucket = hash->buckets[i];
Note:
See TracChangeset
for help on using the changeset viewer.
