00001 // Filename: hashGenerator.h 00002 // Created by: drose (22Mar01) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef DCHASHGENERATOR_H 00016 #define DCHASHGENERATOR_H 00017 00018 #include "dcbase.h" 00019 #include "primeNumberGenerator.h" 00020 00021 //////////////////////////////////////////////////////////////////// 00022 // Class : HashGenerator 00023 // Description : This class generates an arbitrary hash number from a 00024 // sequence of ints. 00025 //////////////////////////////////////////////////////////////////// 00026 class HashGenerator { 00027 public: 00028 HashGenerator(); 00029 00030 void add_int(int num); 00031 void add_string(const string &str); 00032 00033 unsigned long get_hash() const; 00034 00035 private: 00036 long _hash; 00037 int _index; 00038 PrimeNumberGenerator _primes; 00039 }; 00040 00041 #endif