IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 17, 2005, 4:30:50 PM (21 years ago)
Author:
drobbin
Message:

* empty log message *

File:
1 edited

Legend:

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

    r4136 r4315  
    1212*  @author GLG, MHPCC
    1313*
    14 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2005-06-07 22:37:52 $
     14*  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2005-06-18 02:30:49 $
    1616*
    1717*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4343    The linked list
    4444 *****************************************************************************/
    45 psList* psHashKeyList(psHash* table)
     45psList* psHashKeyList(const psHash* hash)
    4646{
    4747    psS32 i = 0;                  // Loop index variable
     
    4949    psHashBucket* ptr = NULL;   // Used to step thru linked list.
    5050
    51     if (table == NULL) {
     51    if (hash == NULL) {
    5252        return NULL;
    5353    }
     
    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 < table->nbucket; i++) {
    60         if (table->buckets[i] != NULL) {
     59    for (i = 0; i < hash->nbucket; i++) {
     60        if (hash->buckets[i] != NULL) {
    6161            // Since a bucket contains a linked list of keys/data, we must
    6262            // step trough each key in that linked list:
    6363
    64             ptr = table->buckets[i];
     64            ptr = hash->buckets[i];
    6565            while (ptr != NULL) {
    6666                psListAdd(myLinkList, PS_LIST_HEAD, ptr->key);
     
    135135    The new hash table.
    136136 *****************************************************************************/
    137 psHash* psHashAlloc(psS32 nbucket)        // initial number of buckets
     137psHash* psHashAlloc(long nalloc)        // initial number of buckets
    138138{
    139139    psS32 i = 0;                  // loop index variable
     
    145145
    146146    // Allocate memory for the buckets.
    147     table->buckets = psAlloc(nbucket * sizeof(psHashBucket* ));
    148     table->nbucket = nbucket;
    149 
    150     psTrace("utils.hash", 1, "Creating %d-element hash table\n", nbucket);
     147    table->buckets = psAlloc(nalloc * sizeof(psHashBucket* ));
     148    table->nbucket = nalloc;
     149
     150    psTrace("utils.hash", 1, "Creating %d-element hash table\n", nalloc);
    151151
    152152    // Initialize all buckets to NULL.
    153     for (i = 0; i < nbucket; i++)
     153    for (i = 0; i < nalloc; i++)
    154154    {
    155155        table->buckets[i] = NULL;
     
    383383    boolean value defining success or failure
    384384 *****************************************************************************/
    385 psBool psHashRemove(psHash* table,
    386                     const char *key)
     385bool psHashRemove(psHash* table,
     386                  const char *key)
    387387{
    388388    psPtr data = NULL;
Note: See TracChangeset for help on using the changeset viewer.