summaryrefslogtreecommitdiff
path: root/decoder/phrasebased_translator.cc
diff options
context:
space:
mode:
authorPaul Baltescu <pauldb89@gmail.com>2013-11-23 17:33:47 +0000
committerPaul Baltescu <pauldb89@gmail.com>2013-11-23 17:33:47 +0000
commitcc6313b23cac25eb05976b6cf64f96faf1ed4163 (patch)
tree3dc28060ad25b43773e875bea7388ab1cefcd927 /decoder/phrasebased_translator.cc
parent7990c750829af93f0a1e0fc14534582f52ee9e8c (diff)
parentf2fb69b10a897e8beb4e6e6d6cbb4327096235ef (diff)
Merge branch 'master' of https://github.com/redpony/cdec
Diffstat (limited to 'decoder/phrasebased_translator.cc')
-rw-r--r--decoder/phrasebased_translator.cc20
1 files changed, 14 insertions, 6 deletions
diff --git a/decoder/phrasebased_translator.cc b/decoder/phrasebased_translator.cc
index d65e44d1..8048248e 100644
--- a/decoder/phrasebased_translator.cc
+++ b/decoder/phrasebased_translator.cc
@@ -2,8 +2,14 @@
#include <queue>
#include <iostream>
-#include <tr1/unordered_map>
-#include <tr1/unordered_set>
+#ifndef HAVE_OLD_CPP
+# include <unordered_map>
+# include <unordered_set>
+#else
+# include <tr1/unordered_map>
+# include <tr1/unordered_set>
+namespace std { using std::tr1::unordered_map; using std::tr1::unordered_set; }
+#endif
#include <boost/tuple/tuple.hpp>
#include <boost/functional/hash.hpp>
@@ -17,7 +23,6 @@
#include "array2d.h"
using namespace std;
-using namespace std::tr1;
using namespace boost::tuples;
struct Coverage : public vector<bool> {
@@ -49,10 +54,13 @@ struct Coverage : public vector<bool> {
};
struct CoverageHash {
size_t operator()(const Coverage& cov) const {
- return hasher_(static_cast<const vector<bool>&>(cov));
+ int seed = 131;
+ size_t res = 0;
+ for (vector<bool>::const_iterator it = cov.begin(); it != cov.end(); ++it) {
+ res = (res * seed) + (*it + 1);
+ }
+ return res;
}
- private:
- boost::hash<vector<bool> > hasher_;
};
ostream& operator<<(ostream& os, const Coverage& cov) {
os << '[';