diff --git a/examples/knucleotide.cc b/examples/knucleotide.cc index 8938d49..2626c28 100644 --- a/examples/knucleotide.cc +++ b/examples/knucleotide.cc @@ -44,7 +44,7 @@ #include #include #include -#include +#include // ------------------------------------------------------------------ struct Cfg { @@ -123,7 +123,7 @@ private: // ------------------------------------------------------------------ template > -using HashTable = std::unordered_map; +using HashTable = phmap::flat_hash_map; // ------------------------------------------------------------------ template @@ -156,7 +156,7 @@ void Calculate(const Cfg::Data& input, size_t begin, HashTable& table) // ------------------------------------------------------------------ template -auto CalculateInThreads(const Cfg::Data& input) +HashTable CalculateInThreads(const Cfg::Data& input) { HashTable hash_tables[cfg.thread_count]; std::thread threads[cfg.thread_count]; @@ -175,6 +175,7 @@ auto CalculateInThreads(const Cfg::Data& input) for(unsigned i = 1 ; i < cfg.thread_count; ++i) for(auto& j : hash_tables[i]) frequencies[j.first] += j.second; + // return the 'frequency' by move instead of copy. return std::move(frequencies); }