#if !defined(PS_HASH_H)
#define PS_HASH_H

/** \file psHash.h
 *  \brief Hash Table manipulation
 *  \ingroup DataGroup
 */

/** A hash table */
typedef struct {
    int nbucket;                        ///< number of buckets
    psHashBucket **buckets;             ///< the buckets themselves
} psHash;

/** The hash buckets, which compose the hash */
typedef struct psHashBucket {
    char *key;                          ///< key for this item of data
    void *data;                         ///< the data itself
    struct psHashBucket *next;          ///< list of other possible keys
} psHashBucket;

/** Functions **************************************************************/
/** \addtogroup DataGroup General Data Container Utilities  
 *  \{
 */

/** Allocate hash buckets in table. */
psHash *psHashAlloc(void);

/** Add entry to table. */
bool psHashAdd(psHash *table,		///< table to insert in
	       const char *key,		///< key to use
	       void *data		///< data to insert
    );

/** Lookup key in table. */
void *psHashLookup(psHash *table,	///< table to lookup key in
		   const char *key	///< key to lookup
    );

/** Remove key from table. */
bool psHashRemove(psHash *table,	///< table to lookup key in
		  const char *key	///< key to lookup
    );

/** Get list of keys */
psList *psHashKeyList(psHash *table	///< table for which to get keys
    );


/* \} */ // End of DataGroup Functions

#endif
