21 #ifndef _libint2_src_bin_libint_hashable_h_ 22 #define _libint2_src_bin_libint_hashable_h_ 24 #include <libint2/util/intrinsic_types.h> 32 template <KeyManagePolicy KeyManage>
struct OwnKey {
enum {result=
false}; };
33 template<>
struct OwnKey<CacheKey> {
enum {result=
true}; };
36 template <
class T,
bool HasAKey>
60 typedef const std::string& ReturnType;
63 template <
typename T,
size_t Size>
66 typedef const T*
const ReturnType;
72 template <
typename KeyType, KeyManagePolicy KeyMP>
76 typedef typename KeyTraits<KeyType>::ReturnType KeyReturnType;
81 virtual KeyReturnType key()
const =0;
97 inline LIBINT2_UINT_LEAST64
hash(
const std::string& S);
101 static const LIBINT2_UINT_LEAST64 hval_init = 0xcbf29ce484222325UL;
102 static const LIBINT2_UINT_LEAST64 fnv_prime64 = 0x100000001b3UL;
104 static const LIBINT2_UINT_LEAST64 hval_init = 0xcbf29ce484222325ULL;
105 static const LIBINT2_UINT_LEAST64 fnv_prime64 = 0x100000001b3ULL;
107 LIBINT2_UINT_LEAST64 hval_;
112 const unsigned char* cS = reinterpret_cast<const unsigned char*>(S.c_str());
113 const unsigned char* cptr = cS;
115 hval_ ^= (LIBINT2_UINT_LEAST64)*cptr;
117 hval_ *= fnv_prime64;
KeyTraits<T> describes following properties of type T: 1) how to return objects of type T.
Definition: hashable.h:52
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:24
Objects of Hashable<T> class provide hashing function key() which computes keys of type KeyType.
Definition: hashable.h:73
KeyManagePolicy
KeyManagePolicy defines whether to compute+cache, compute, or key is just an object.
Definition: hashable.h:29
FNVStringHash uses Fowler/Noll/Vo algorithm to hash a char string to a 64-bit integer.
Definition: hashable.h:88
LIBINT2_UINT_LEAST64 KeyType
The type of key computed using this hash.
Definition: hashable.h:91
use OwnKey to figure out whether the key should be stored in Hashable
Definition: hashable.h:32
If OwnsKey is true then KeyStore<T> has the key of type T, otherwise it's empty.
Definition: hashable.h:37
LIBINT2_UINT_LEAST64 hash(const std::string &S)
Returns 64-bit integer hash of S.
Definition: hashable.h:111