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