Jpp  17.3.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JHashEvaluator.hh
Go to the documentation of this file.
1 #ifndef __JTOOLS__JHASHEVALUATOR__
2 #define __JTOOLS__JHASHEVALUATOR__
3 
4 
5 /**
6  * \author mdejong
7  */
8 
9 namespace JTOOLS {}
10 namespace JPP { using namespace JTOOLS; }
11 
12 namespace JTOOLS {
13 
14  /**
15  * Auxiliary class for default hash key evaluation.
16  *
17  * For a composite hash key, the following policy member method should be provided.
18  * <pre>
19  * int %getKey() const;
20  * </pre>
21  *
22  * For integral primitive data types, the hash value is obtained by a simple cast to an <tt>int</tt> value.
23  */
24  struct JHashEvaluator {
25  /**
26  * Get hash value.
27  *
28  * \param key key
29  * \return hash value
30  */
31  template<class JKey_t>
32  inline int operator()(const JKey_t& key) const
33  {
34  return key.getKey();
35  }
36 
37  inline int operator()(const char key) const { return (int) key; } //!< Get hash value.
38  inline int operator()(const unsigned char key) const { return (int) key; } //!< Get hash value.
39  inline int operator()(const short key) const { return (int) key; } //!< Get hash value.
40  inline int operator()(const unsigned short key) const { return (int) key; } //!< Get hash value.
41  inline int operator()(const int key) const { return (int) key; } //!< Get hash value.
42  inline int operator()(const unsigned int key) const { return (int) key; } //!< Get hash value.
43  inline int operator()(const long int key) const { return (int) key; } //!< Get hash value.
44  inline int operator()(const unsigned long int key) const { return (int) key; } //!< Get hash value.
45  inline int operator()(const long long int key) const { return (int) key; } //!< Get hash value.
46  inline int operator()(const unsigned long long int key) const { return (int) key; } //!< Get hash value.
47  };
48 }
49 
50 #endif
int operator()(const short key) const
Get hash value.
int operator()(const long long int key) const
Get hash value.
int operator()(const char key) const
Get hash value.
int operator()(const unsigned int key) const
Get hash value.
int operator()(const int key) const
Get hash value.
int operator()(const unsigned long int key) const
Get hash value.
int operator()(const long int key) const
Get hash value.
int operator()(const JKey_t &key) const
Get hash value.
Auxiliary class for default hash key evaluation.
int operator()(const unsigned long long int key) const
Get hash value.
int operator()(const unsigned short key) const
Get hash value.
int operator()(const unsigned char key) const
Get hash value.