summaryrefslogtreecommitdiff
path: root/decoder/hash.h
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-24 21:18:01 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-24 21:18:01 +0000
commit5bc0b9b1fc76064d13d2c553c019a381ee52dfa1 (patch)
tree6871a265a8dcf07c4e08a0fee79b4f3e5696bc4b /decoder/hash.h
parent22e857a27ab9755b1f8655b0dcd94ac77cb790b8 (diff)
FSA: simpler Scan1 ScanT1 methods, otherewise also expose edge to full Scan
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@399 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/hash.h')
-rwxr-xr-xdecoder/hash.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/decoder/hash.h b/decoder/hash.h
index 3e4ad1ff..3a60a429 100755
--- a/decoder/hash.h
+++ b/decoder/hash.h
@@ -1,6 +1,8 @@
#ifndef CDEC_HASH_H
#define CDEC_HASH_H
+#include "murmur_hash.h"
+
#include "config.h"
#ifdef HAVE_SPARSEHASH
# include <google/dense_hash_map>
@@ -13,7 +15,40 @@
# define HASH_MAP_RESERVED(h,empty,deleted)
# define HASH_MAP_EMPTY(h,empty)
#endif
+
#include <boost/functional/hash.hpp>
+// assumes C is POD
+template <class C>
+struct murmur_hash
+{
+ typedef MurmurInt return_type;
+ typedef C /*const&*/ argument_type;
+ return_type operator()(argument_type const& c) const {
+ return MurmurHash((void*)&c,sizeof(c));
+ }
+};
+
+// murmur_hash_array isn't std guaranteed safe (you need to use string::data())
+template <>
+struct murmur_hash<std::string>
+{
+ typedef MurmurInt return_type;
+ typedef std::string /*const&*/ argument_type;
+ return_type operator()(argument_type const& c) const {
+ return MurmurHash(c.data(),c.size());
+ }
+};
+
+// uses begin(),size() assuming contiguous layout and POD
+template <class C>
+struct murmur_hash_array
+{
+ typedef MurmurInt return_type;
+ typedef C /*const&*/ argument_type;
+ return_type operator()(argument_type const& c) const {
+ return MurmurHash(&*c.begin(),c.size()*sizeof(*c.begin()));
+ }
+};
#endif