summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdecoder/apply_fsa_models.cc5
-rwxr-xr-xutils/hash.h3
-rw-r--r--utils/small_vector.h17
3 files changed, 15 insertions, 10 deletions
diff --git a/decoder/apply_fsa_models.cc b/decoder/apply_fsa_models.cc
index c9bda68b..8771863c 100755
--- a/decoder/apply_fsa_models.cc
+++ b/decoder/apply_fsa_models.cc
@@ -10,6 +10,7 @@
#include "cfg.h"
#include "hg_cfg.h"
#include "utoa.h"
+#include "hash.h"
using namespace std;
@@ -26,12 +27,12 @@ typedef CFG::RuleHandle RuleHandle;
namespace {
// if we don't greedy-binarize, we want to encode recognized prefixes p (X -> p . rest) efficiently. if we're doing this, we may as well also push costs so we can best-first select rules in a lazy fashion. this is effectively left-branching binarization, of course.
-template <class K,class V>
+template <class K,class V,class Hash>
struct prefix_map_type {
typedef std::map<K,V> type;
};
//template typedef
-#define PREFIX_MAP(k,v) prefix_map_type<k,v>::type
+#define PREFIX_MAP(k,v) prefix_map_type<k,v,boost::hash<k> >::type
typedef NTHandle LHS;
struct PrefixTrieNode {
prob_t backward; // (viterbi) backward prob (for cost pushing)
diff --git a/utils/hash.h b/utils/hash.h
index b0b1c43e..20764860 100755
--- a/utils/hash.h
+++ b/utils/hash.h
@@ -1,6 +1,8 @@
#ifndef CDEC_HASH_H
#define CDEC_HASH_H
+#include <boost/functional/hash.hpp>
+
#include "murmur_hash.h"
#include "config.h"
@@ -16,7 +18,6 @@
# define HASH_MAP_EMPTY(h,empty)
#endif
-#include <boost/functional/hash.hpp>
// assumes C is POD
template <class C>
diff --git a/utils/small_vector.h b/utils/small_vector.h
index 8c1c3bfe..f1e53a51 100644
--- a/utils/small_vector.h
+++ b/utils/small_vector.h
@@ -252,13 +252,12 @@ public:
swap_pod(*this,o);
}
- inline std::size_t hash() const {
- using namespace boost;
+ inline std::size_t hash_impl() const {
if (size_==0) return 0;
- if (size_==1) return hash_value(data_.vals[0]);
+// if (size_==1) return boost::hash_value(data_.vals[0]);
if (size<= SV_MAX)
- return hash_range(data_.vals,data_.vals+size_);
- return hash_range(data_.ptr,data_.ptr+size_);
+ return boost::hash_range(data_.vals,data_.vals+size_);
+ return boost::hash_range(data_.ptr,data_.ptr+size_);
}
private:
@@ -271,9 +270,13 @@ public:
uint16_t capacity_; // only defined when size_ > __SV_MAX_STATIC
};
+namespace boost {
+// shouldn't need to nest this, but getting into trouble with tr1::hash linkage
+}
+
template <class T,int M>
-std::size_t hash_value(SmallVector<T,M> const& x) {
- return x.hash();
+inline std::size_t hash_value(SmallVector<T,M> const& x) {
+ return x.hash_impl();
}
template <class T,int M>