summaryrefslogtreecommitdiff
path: root/utils/hash.h
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-11 02:46:13 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-11 02:46:13 +0000
commit82384b4ec365f3d2ad2c9bca078a0b38d4be09c0 (patch)
treef6f015f2791ec9b1ec94c90c98b09c0d251aee9e /utils/hash.h
parente4e66118c14704509e214aa32689ef304ae5ada2 (diff)
merge
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@511 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'utils/hash.h')
-rwxr-xr-xutils/hash.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/utils/hash.h b/utils/hash.h
index 3a60a429..5d7f2010 100755
--- a/utils/hash.h
+++ b/utils/hash.h
@@ -51,4 +51,10 @@ struct murmur_hash_array
}
};
+// adds default val to table if key wasn't found, returns ref to val
+template <class H,class K>
+typename H::data_type & get_default(H &ht,K const& k,typename H::data_type const& v) {
+ return const_cast<typename H::data_type &>(ht.insert(typename H::value_type(k,v)).first->second);
+}
+
#endif