/**************************************************************************
 * Source Id :
 *
 * $Id: hash.h,v 1.1 2001/04/03 20:10:26 aleksandras Exp $
 *-------------------------------------------------------------------------
 * Project Notes :
 *
 *  Diamond Base
 *  ============
 *      A solid database implementation, spurred on by the continuing
 *  Metal (Lead) Base saga.
 *
 *  Project Team :
 *        A. Davison
 *        K. Lentin
 *        D. Platt
 *
 *	Project Commenced : 05-02-1993
 *
 *-------------------------------------------------------------------------
 *  Module Notes :
 *
 *  Simple hash table module hashes int->void *
 *
 *  Original Author : Darren Platt
 *
 **************************************************************************/

#ifndef HASH_INCL
#define HASH_INCL

#include <diamond/defs.h>

//
// Hash table definition
//

struct DiaHashBucket {
	int32 value;
	void *ptr;
	DiaHashBucket *next;

};

class DiaHash {
	private:
		DiaHashBucket **bucket;
		int 	numBuckets;

		int 	hashToBucket(int32 key);

		DiaHashBucket *nextBucket;
		int		currBucket;

	public:
		DiaHash(int numBuckets = 101);
		~DiaHash();

		void * operator [] (int32 key);

		void add(int32 key,void *ptr);
		void del(int32 key);

		void *first(void);
		void *next(void);
		bool last(void);
};

#endif
