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

psHash.h

Go to the documentation of this file.
00001 /** @file  psHash.h
00002  *  @brief Contains support for basic hashing functions.
00003  *  @ingroup HashTable
00004  *
00005  *  This file will hold the prototypes for defining a hash table with arbitrary
00006  *  data types, allocating/deallocating that has table, adding and removing
00007  *  data from that hash table, and listing all keys defined in the hash table.
00008  *
00009  *  @author Robert Lupton, Princeton University
00010  *  @author Robert DeSonia, MHPCC
00011  *  @author GLG, MHPCC
00012  *
00013  *  @version $Revision: 1.1.1.1 $ $Name:  $
00014  *  @date $Date: 2005/06/15 21:08:12 $
00015  *
00016  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00017  */
00018 
00019 #ifndef 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;                         ///< The key for this item of data.
00032     psPtr data;                        ///< The data itself.
00033     struct psHashBucket* next;         ///< The 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,                 ///< The table to insert in.
00055     const char *key,               ///< The key to use.
00056     psPtr data                     ///< The data to insert.
00057 );
00058 
00059 /// Lookup key in table.
00060 psPtr psHashLookup(
00061     psHash* table,                 ///< The table to lookup key in.
00062     const char *key                ///< The key to lookup.
00063 );
00064 
00065 /// Remove key from table.
00066 psBool psHashRemove(
00067     psHash* table,                 ///< The table to lookup key in.
00068     const char *key                ///< The key to lookup.
00069 );
00070 
00071 /// List all keys in table.
00072 psList* psHashKeyList(
00073     psHash* table                  ///< The 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                  ///< The table to convert to psArray.
00082 );
00083 
00084 /* \} */// End of DataGroup Functions
00085 
00086 #endif // #ifndef PS_HASH_H

Generated on Wed Jun 15 11:00:57 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.1