IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 5, 2005, 5:04:35 PM (21 years ago)
Author:
drobbin
Message:

made changes based on revisions in psLib SDRS rev. 15

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/collections/psHash.c

    r4392 r4457  
    1212*  @author GLG, MHPCC
    1313*
    14 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2005-06-25 02:02:05 $
     14*  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2005-07-06 03:04:35 $
    1616*
    1717*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5757    // Loop through every bucket in the hash table.  If that bucket is not
    5858    // NULL, then add the bucket's key to the linked list.
    59     for (i = 0; i < hash->nbucket; i++) {
     59    for (i = 0; i < hash->n; i++) {
    6060        if (hash->buckets[i] != NULL) {
    6161            // Since a bucket contains a linked list of keys/data, we must
     
    128128
    129129/******************************************************************************
    130 psHashAlloc(nbucket): this procedure creates a new hash table with the
     130psHashAlloc(n): this procedure creates a new hash table with the
    131131specified number of buckets.
    132132Inputs:
    133     nbucket: initial number of buckets
     133    n: initial number of buckets
    134134Return:
    135135    The new hash table.
     
    146146    // Allocate memory for the buckets.
    147147    table->buckets = psAlloc(nalloc * sizeof(psHashBucket* ));
    148     table->nbucket = nalloc;
     148    table->n = nalloc;
    149149
    150150    psTrace("utils.hash", 1, "Creating %d-element hash table\n", nalloc);
     
    179179    // Loop through each bucket in the hash table.  If that bucket is not
    180180    // NULL, then free the bucket via a function call to hashBucketFree();
    181     for (i = 0; i < table->nbucket; i++) {
     181    for (i = 0; i < table->n; i++) {
    182182
    183183        // A bucket is composed of a linked list of buckets.
     
    238238    // hash = (hash << 1) ^ key[i];
    239239    // }
    240     // hash &= (table->nbucket - 1);
     240    // hash &= (table->n - 1);
    241241
    242242    // This hash algorithm is from Sedgewick.  NOTE: must reread to ensure that
     
    244244    tmpchar = (char *)key;
    245245    for (hash = 0; *tmpchar != '\0'; tmpchar++) {
    246         hash = (64 * hash + *tmpchar) % (table->nbucket);
     246        hash = (64 * hash + *tmpchar) % (table->n);
    247247    }
    248248
    249249    // NOTE: This should not be necessary, but for now, I'm checking bounds
    250250    // anyway.
    251     if ((hash < 0) || (hash >= table->nbucket)) {
     251    if ((hash < 0) || (hash >= table->n)) {
    252252        psError(PS_ERR_UNKNOWN, true,
    253253                "Internal hash function out of range (%d)", hash);
     
    409409    // psArray we need to allocate.
    410410    int nElements = 0;
    411     int nbucket = hash->nbucket;
     411    int nbucket = hash->n;
    412412    for (int i = 0; i < nbucket; i++) {
    413413        psHashBucket* tmpBucket = hash->buckets[i];
Note: See TracChangeset for help on using the changeset viewer.