diff options
author | Wu, Ke <wuke@cs.umd.edu> | 2014-12-17 16:15:13 -0500 |
---|---|---|
committer | Wu, Ke <wuke@cs.umd.edu> | 2014-12-17 16:15:13 -0500 |
commit | 17dbb7d5ab1544899b1b9e867d2246a0a93e3aa8 (patch) | |
tree | 7fa2a51763a1b67fb325e86b0e3f764dd119cd70 /klm/util/probing_hash_table.hh | |
parent | 1983c75c35b7f5dc3f356a2f9a9345d632b87650 (diff) | |
parent | 1613f1fc44ca67820afd7e7b21eb54b316c8ce55 (diff) |
Merge branch 'const_reorder_2' into softsyn_2
Diffstat (limited to 'klm/util/probing_hash_table.hh')
-rw-r--r-- | klm/util/probing_hash_table.hh | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/klm/util/probing_hash_table.hh b/klm/util/probing_hash_table.hh index 38524806..ea228dd9 100644 --- a/klm/util/probing_hash_table.hh +++ b/klm/util/probing_hash_table.hh @@ -1,5 +1,5 @@ -#ifndef UTIL_PROBING_HASH_TABLE__ -#define UTIL_PROBING_HASH_TABLE__ +#ifndef UTIL_PROBING_HASH_TABLE_H +#define UTIL_PROBING_HASH_TABLE_H #include "util/exception.hh" #include "util/scoped.hh" @@ -258,6 +258,10 @@ template <class EntryT, class HashT, class EqualT = std::equal_to<typename Entry private: typedef ProbingHashTable<EntryT, HashT, EqualT> Backend; public: + static std::size_t MemUsage(std::size_t size, float multiplier = 1.5) { + return Backend::Size(size, multiplier); + } + typedef EntryT Entry; typedef typename Entry::Key Key; typedef const Entry *ConstIterator; @@ -268,6 +272,7 @@ template <class EntryT, class HashT, class EqualT = std::equal_to<typename Entry AutoProbing(std::size_t initial_size = 10, const Key &invalid = Key(), const Hash &hash_func = Hash(), const Equal &equal_func = Equal()) : allocated_(Backend::Size(initial_size, 1.5)), mem_(util::MallocOrThrow(allocated_)), backend_(mem_.get(), allocated_, invalid, hash_func, equal_func) { threshold_ = initial_size * 1.2; + Clear(); } // Assumes that the key is unique. Multiple insertions won't cause a failure, just inconsistent lookup. @@ -323,4 +328,4 @@ template <class EntryT, class HashT, class EqualT = std::equal_to<typename Entry } // namespace util -#endif // UTIL_PROBING_HASH_TABLE__ +#endif // UTIL_PROBING_HASH_TABLE_H |