summaryrefslogtreecommitdiff
path: root/src/old/hashfunction.h
blob: cbcf70f8ee4f20c6c7ac7921177fa90c6e71ce70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef HASH_FUNCTION
#define HASH_FUNCTION

/** This represents the shell of a hash function.  It must be aggregated in
  * order to be used.  Please read about it's two functions for specificatins
  * relating to what values will be passed to them and what they should return
  * for creating your own hash functions.
  *@author Mike Buland.
  */
class HashFunction
{
public:
	/**
	 * Standard Constructor.
	 */
	HashFunction();

	/**
	 * Standard Deconstructor.
	 */
	virtual ~HashFunction();

	/** Hashes the value represnted by id.  This must return a fairly unique
	  * number in the range of 0-2^32 (or whatever the size of an unsigned long
	  * is on your system) based on the id given.  The faster the number changes
	  * the better in a general sence.  The return value will be the index
	  * (after probing takes place) to the data assosiated with an id, so this
	  * function should always produce the same number for any given id.
	  *@param id The identifier to use to create a unique numerical identifier.
	  *@returns A mostly unique numerical identifier generated using the given
	  * id.
	  */
	virtual unsigned long int hash( const void *id ) = 0;

	/** This function must compare two ids in the format that this hashfunction
	  * accepts.  For example, if the hash function hashes strings it should
	  * probably { return strcmp( id1, id2 ) == 0 }.
	  *@param id1 One value to use in the comparison
	  *@param id2 Another value to use in the comparison
	  *@returns True if the two values match, otherwise false.
	  */
	virtual bool cmpIDs( const void *id1, const void *id2 ) = 0;
	
//	virtual void *createPersistantID( const void *id ) = 0;
//	virtual void destroyPersistantID( const void *id ) = 0;
};

#endif