summaryrefslogtreecommitdiff
path: root/decoder
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-20 21:38:29 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-20 21:38:29 +0000
commitcd5d8e0ab902a0c87e108b863aca2888248a4516 (patch)
tree27118981b820e8e5f4663baf8be195a19b1c8ab1 /decoder
parent07e718c343f0e3cde63d3bed94cdba56c222007d (diff)
hash.h
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@342 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder')
-rw-r--r--decoder/dict.h22
-rw-r--r--decoder/ff_factory.h2
-rwxr-xr-xdecoder/hash.h19
3 files changed, 24 insertions, 19 deletions
diff --git a/decoder/dict.h b/decoder/dict.h
index dd433c3e..348a97e3 100644
--- a/decoder/dict.h
+++ b/decoder/dict.h
@@ -1,37 +1,21 @@
#ifndef DICT_H_
#define DICT_H_
-#include "config.h"
#include <cassert>
#include <cstring>
-#ifdef HAVE_SPARSEHASH
-# include <google/dense_hash_map>
-#else
-# include <tr1/unordered_map>
-#endif
#include <string>
#include <vector>
-#include <boost/functional/hash.hpp>
-
+#include "hash.h"
#include "wordid.h"
class Dict {
typedef
-#ifdef HAVE_SPARSEHASH
- google::dense_hash_map
-#else
- std::tr1::unordered_map
-#endif
- <std::string, WordID, boost::hash<std::string> > Map;
-
+ HASH_MAP<std::string, WordID, boost::hash<std::string> > Map;
public:
Dict() : b0_("<bad0>") {
-#ifdef HAVE_SPARSEHASH
- d_.set_empty_key("<bad1>");
- d_.set_deleted_key("<bad2>");
-#endif
+ HASH_MAP_EMPTY(d_,"<bad1>");
words_.reserve(1000);
}
diff --git a/decoder/ff_factory.h b/decoder/ff_factory.h
index 6f86f2f9..12e768aa 100644
--- a/decoder/ff_factory.h
+++ b/decoder/ff_factory.h
@@ -1,6 +1,8 @@
#ifndef _FF_FACTORY_H_
#define _FF_FACTORY_H_
+//TODO: use http://www.boost.org/doc/libs/1_43_0/libs/functional/factory/doc/html/index.html?
+
#include <iostream>
#include <string>
#include <map>
diff --git a/decoder/hash.h b/decoder/hash.h
new file mode 100755
index 00000000..3e4ad1ff
--- /dev/null
+++ b/decoder/hash.h
@@ -0,0 +1,19 @@
+#ifndef CDEC_HASH_H
+#define CDEC_HASH_H
+
+#include "config.h"
+#ifdef HAVE_SPARSEHASH
+# include <google/dense_hash_map>
+# define HASH_MAP google::dense_hash_map
+# define HASH_MAP_RESERVED(h,empty,deleted) do { h.set_empty_key(empty); h.set_deleted_key(deleted); } while(0)
+# define HASH_MAP_EMPTY(h,empty) do { h.set_empty_key(empty); } while(0)
+#else
+# include <tr1/unordered_map>
+# define HASH_MAP std::tr1::unordered_map
+# define HASH_MAP_RESERVED(h,empty,deleted)
+# define HASH_MAP_EMPTY(h,empty)
+#endif
+#include <boost/functional/hash.hpp>
+
+
+#endif