Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

psHash.h

Go to the documentation of this file.
00001 
00002 /** @file  psHash.h
00003  *  @brief Contains support for basic hashing functions.
00004  *  @ingroup HashTable
00005  *
00006  *  This file will hold the prototypes for defining a hash table with arbitrary
00007  *  data types, allocating/deallocating that has table, adding and removing
00008  *  data from that hash table, and listing all keys defined in the hash table.
00009  *
00010  *  @author Robert Lupton, Princeton University
00011  *  @author George Gusciora, MHPCC
00012  *  @author Robert DeSonia, MHPCC
00013  *
00014  *  @version $Revision: 1.7 $ $Name: rel5_0 $
00015  *  @date $Date: 2005/02/17 19:26:23 $
00016  *
00017  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00018  */
00019 #if !defined(PS_HASH_H)
00020 #define PS_HASH_H
00021 
00022 /** \addtogroup HashTable
00023  *  \{
00024  */
00025 
00026 #include "psList.h"
00027 
00028 /** A bucket that holds an item of data. */
00029 typedef struct psHashBucket
00030 {
00031     char *key;                         ///< key for this item of data
00032     psPtr data;                        ///< the data itself
00033     struct psHashBucket* next;         ///< list of other possible keys
00034 }
00035 psHashBucket;
00036 
00037 //typedef struct HashTable psHash; ///< Opaque type for a hash table
00038 
00039 /** The hash-table itself. */
00040 typedef struct psHash
00041 {
00042     psS32 nbucket;                     ///< Number of buckets in hash table.
00043     psHashBucket* *buckets;            ///< The bucket data.
00044 }
00045 psHash;
00046 
00047 /// Allocate hash buckets in table.
00048 psHash* psHashAlloc(
00049     psS32 nbucket                  ///< The number of buckets to allocate.
00050 );
00051 
00052 /// Insert entry into table.
00053 psBool psHashAdd(
00054     psHash* table,                 ///< table to insert in
00055     const char *key,               ///< key to use
00056     psPtr data                     ///< data to insert
00057 );
00058 
00059 /// Lookup key in table.
00060 psPtr psHashLookup(
00061     psHash* table,                 ///< table to lookup key in
00062     const char *key                ///< key to lookup
00063 );
00064 
00065 /// Remove key from table.
00066 psBool psHashRemove(
00067     psHash* table,                 ///< table to lookup key in
00068     const char *key                ///< key to lookup
00069 );
00070 
00071 /// List all keys in table.
00072 psList* psHashKeyList(
00073     psHash* table                  ///< table to list keys from.
00074 );
00075 
00076 /** Create a psArray from a psHash contents.
00077  *
00078  *  @return psArray*       A new psArray with duplicate contents of the input psHash
00079  */
00080 psArray* psHashToArray(
00081     psHash* table                  ///< table to convert to psArray
00082 );
00083 
00084 /* \} */// End of DataGroup Functions
00085 
00086 #endif

Generated on Mon Apr 4 18:24:45 2005 for Pan-STARRS Foundation Library by  doxygen 1.3.9.1