diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2018-12-10 16:27:57 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2018-12-10 16:27:57 +0300 |
commit | dd9ff66479e694f94c067e168695f5c215011635 (patch) | |
tree | f675beac89838a97930aa96e65a285b64563eab4 | |
parent | baefaa1b12e540ec21d008d20031cb76fa1764a3 (diff) |
put fix into UnorderedComparer again. Maybe weird template bug
-rw-r--r-- | moses2/HypothesisColl.h | 21 | ||||
-rw-r--r-- | moses2/SCFG/Misc.h | 2 | ||||
-rw-r--r-- | moses2/legacy/Bitmaps.h | 2 | ||||
-rw-r--r-- | moses2/legacy/Util2.h | 15 |
4 files changed, 9 insertions, 31 deletions
diff --git a/moses2/HypothesisColl.h b/moses2/HypothesisColl.h index bd111f373..9c17fc9e7 100644 --- a/moses2/HypothesisColl.h +++ b/moses2/HypothesisColl.h @@ -20,25 +20,6 @@ class ArcLists; typedef Array<const HypothesisBase*> Hypotheses; -class HypoHash -{ -public: - size_t operator()(const HypothesisBase* obj) const { - return obj->hash(); - } - -}; - -class HypoEqualTo -{ -public: - bool operator()(const HypothesisBase* a, const HypothesisBase* b) const { - return a->hash() == b->hash(); - } - -}; - - //////////////////////////////////////////////////// class HypothesisColl { @@ -74,7 +55,7 @@ public: protected: typedef boost::unordered_set<const HypothesisBase*, - HypoHash, HypoEqualTo, + UnorderedComparer<HypothesisBase>, UnorderedComparer<HypothesisBase>, MemPoolAllocator<const HypothesisBase*> > _HCType; _HCType m_coll; diff --git a/moses2/SCFG/Misc.h b/moses2/SCFG/Misc.h index 27b9df79a..85c758440 100644 --- a/moses2/SCFG/Misc.h +++ b/moses2/SCFG/Misc.h @@ -61,7 +61,7 @@ public: protected: typedef boost::unordered_set<const SeenPosition*, - UnorderedComparer<SeenPosition>, UnorderedComparer<SeenPosition> > Coll; + UnorderedComparer<SeenPosition>, UnorderedComparer<SeenPosition> > Coll; Coll m_coll; }; diff --git a/moses2/legacy/Bitmaps.h b/moses2/legacy/Bitmaps.h index aa0ea8f82..c6061033d 100644 --- a/moses2/legacy/Bitmaps.h +++ b/moses2/legacy/Bitmaps.h @@ -15,7 +15,7 @@ class Bitmaps { typedef boost::unordered_map<const Range*, const Bitmap*> NextBitmaps; typedef boost::unordered_map<const Bitmap*, NextBitmaps, - UnorderedComparer<Bitmap>, UnorderedComparer<Bitmap> > Coll; + UnorderedComparer<Bitmap>, UnorderedComparer<Bitmap> > Coll; //typedef std::set<const Bitmap*, OrderedComparer<Bitmap> > Coll; Coll m_coll; Bitmap *m_initBitmap; diff --git a/moses2/legacy/Util2.h b/moses2/legacy/Util2.h index c2b8cf58f..fe84cb039 100644 --- a/moses2/legacy/Util2.h +++ b/moses2/legacy/Util2.h @@ -26,28 +26,25 @@ namespace Moses2 #define TRACE_ERR(str) do {} while (false) #endif +//////////////////////////////////////////////////// + template<typename T> class UnorderedComparer { public: - size_t operator()(const T& obj) const { - return obj.hash(); - } - - bool operator()(const T& a, const T& b) const { - return a == b; - } - size_t operator()(const T* obj) const { return obj->hash(); } bool operator()(const T* a, const T* b) const { - return (*a) == (*b); + return a->hash() == b->hash(); } }; +//////////////////////////////////////////////////// + + template<typename T> void Init(T arr[], size_t size, const T &val) { |