summaryrefslogtreecommitdiff
path: root/utils/intern_pool.h
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-31 01:08:42 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-31 01:08:42 +0000
commit2af5a445f3905c69c42be5c758c52a2f21b17446 (patch)
treeb970b770210046d6a1b41d3385084dd7d4d06961 /utils/intern_pool.h
parent61be4c3048df90d7decdbe4caf91d7ed80433a3f (diff)
l2r bugfixes
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@634 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'utils/intern_pool.h')
-rwxr-xr-xutils/intern_pool.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/utils/intern_pool.h b/utils/intern_pool.h
index d9890ae6..7c739add 100755
--- a/utils/intern_pool.h
+++ b/utils/intern_pool.h
@@ -59,6 +59,30 @@ struct compose_indirect {
};
+template <class KeyF,class F,class Arg=typename KeyF::argument_type>
+struct equal_indirect {
+ typedef Arg *argument_type; // we also accept Arg &
+ KeyF kf;
+ F f;
+ typedef bool result_type;
+
+ result_type operator()(Arg const& a1,Arg const& a2) const {
+ return f(kf(a1),kf(a2));
+ }
+ result_type operator()(Arg & a1,Arg & a2) const {
+ return f(kf(a1),kf(a2));
+ }
+ result_type operator()(Arg * a1,Arg * a2) const {
+ return a1==a2||(a1&&a2&&f(kf(*a1),kf(*a2)));
+ }
+ template <class V,class W>
+ result_type operator()(V const& v,W const&w) const {
+ return v==w||(v&&w&&f(kf(*v),kf(*w)));
+ }
+
+
+};
+
/*
template <class F>
@@ -79,7 +103,7 @@ struct intern_pool : Pool {
typedef typename KeyF::result_type Key;
typedef Item *Handle;
typedef compose_indirect<KeyF,HashKey,Item> HashDeep;
- typedef compose_indirect<KeyF,EqKey,Item> EqDeep;
+ typedef equal_indirect<KeyF,EqKey,Item> EqDeep;
typedef HASH_SET<Handle,HashDeep,EqDeep> Canonical;
typedef typename Canonical::iterator CFind;
typedef std::pair<CFind,bool> CInsert;