diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-20 21:38:29 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-20 21:38:29 +0000 |
commit | e350d445a6a65ff1fa759911a785775b3152952f (patch) | |
tree | 626befbd6a788f42e26c3dac11e2b99f57314b9f /decoder | |
parent | dc579e9ab5e23a63e5bf2d7688ca50ae307cc514 (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.h | 22 | ||||
-rw-r--r-- | decoder/ff_factory.h | 2 | ||||
-rwxr-xr-x | decoder/hash.h | 19 |
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 |