diff options
Diffstat (limited to 'utils/hash.h')
-rwxr-xr-x | utils/hash.h | 6 |
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 |