From 86bb77e674c4df9c46e3e2d8bba8a5c8b42bb98c Mon Sep 17 00:00:00 2001 From: graehl Date: Fri, 13 Aug 2010 08:31:51 +0000 Subject: boost::hash git-svn-id: https://ws10smt.googlecode.com/svn/trunk@541 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/cfg.cc | 2 +- utils/hash.h | 1 + utils/small_vector.h | 9 +++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/decoder/cfg.cc b/decoder/cfg.cc index a279c74a..c2d96b33 100755 --- a/decoder/cfg.cc +++ b/decoder/cfg.cc @@ -109,7 +109,7 @@ struct prob_pos { }//ns void CFG::UniqRules(NTHandle ni) { - typedef HASH_MAP BestRHS; // faster to use trie? maybe. + typedef HASH_MAP > BestRHS; // faster to use trie? maybe. BestRHS bestp; // once inserted, the position part (output index) never changes. but the prob may be improved (overwrite ruleid at that position). HASH_MAP_EMPTY(bestp,null_rhs); Ruleids &adj=nts[ni].ruleids; diff --git a/utils/hash.h b/utils/hash.h index 20764860..fbe10b4e 100755 --- a/utils/hash.h +++ b/utils/hash.h @@ -18,6 +18,7 @@ # define HASH_MAP_EMPTY(h,empty) #endif +#define BOOST_HASHED_MAP(k,v) HASH_MAP > // assumes C is POD template diff --git a/utils/small_vector.h b/utils/small_vector.h index f1e53a51..89917d1c 100644 --- a/utils/small_vector.h +++ b/utils/small_vector.h @@ -253,11 +253,12 @@ public: } inline std::size_t hash_impl() const { + using namespace boost; if (size_==0) return 0; -// if (size_==1) return boost::hash_value(data_.vals[0]); - if (size<= SV_MAX) - return boost::hash_range(data_.vals,data_.vals+size_); - return boost::hash_range(data_.ptr,data_.ptr+size_); + if (size_==1) return 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_); } private: -- cgit v1.2.3