Panda3D
hashGenerator.h
1 // Filename: hashGenerator.h
2 // Created by: drose (22Mar01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef DCHASHGENERATOR_H
16 #define DCHASHGENERATOR_H
17 
18 #include "dcbase.h"
19 #include "primeNumberGenerator.h"
20 
21 ////////////////////////////////////////////////////////////////////
22 // Class : HashGenerator
23 // Description : This class generates an arbitrary hash number from a
24 // sequence of ints.
25 ////////////////////////////////////////////////////////////////////
27 public:
28  HashGenerator();
29 
30  void add_int(int num);
31  void add_string(const string &str);
32 
33  unsigned long get_hash() const;
34 
35 private:
36  long _hash;
37  int _index;
38  PrimeNumberGenerator _primes;
39 };
40 
41 #endif
void add_string(const string &str)
Adds a string to the hash, by breaking it down into a sequence of integers.
void add_int(int num)
Adds another integer to the hash so far.
This class generates a table of prime numbers, up to the limit of an int.
This class generates an arbitrary hash number from a sequence of ints.
Definition: hashGenerator.h:26
unsigned long get_hash() const
Returns the hash number generated.