hash_classes.h

Go to the documentation of this file.
00001 
00017 #ifndef HASH_CLASSES_H
00018 #define HASH_CLASSES_H
00019 
00020 #include "util.h"
00021 
00023 class ControlPointHasher{
00024 public:
00025   unsigned long long operator()(ControlPoint cp) const { return (unsigned long long)( 389 * ( (unsigned long long)(&(*cp)) >> 2) ); }
00026 };
00027 
00029 template<class Tuple>
00030 class TupleHasher{
00031 public:
00032     unsigned long long operator()(const Tuple& t) const{
00033       return (unsigned long long)( 997*((unsigned long long)(t.v) >> 2) + 389*((unsigned long long)(t.e) >> 2) + 773*((unsigned long long)(t.f) >> 2) );
00034     }
00035 };
00036 
00038 template<class CellA, class CellB>
00039 class PairHasher{
00040 public:
00041     unsigned long long operator()(const std::pair<CellA,CellB> &p) const {
00042       return (unsigned long long)( 997*((unsigned long long)(p.first) >> 2) + 389*((unsigned long long)(p.second) >> 2) );
00043     }
00044 };
00045 
00046 /* Use the cast operator to generate a hash function. */
00047 template<class T>
00048 struct CastHash {
00049   unsigned long operator()(const T& t) const {
00050     return (unsigned long)t;
00051   }
00052 };
00053 
00054 #endif /* HASH_CLASSES_H */

Generated on Mon May 24 09:53:30 2010 for TUMBLE by  doxygen 1.5.2