tudocomp
– The TU Dortmund Compression Framework
StdUnorderedMapIPD.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <tudocomp/Algorithm.hpp>
4 
5 namespace tdc {namespace esp {
6  class StdUnorderedMapIPD: public Algorithm {
7  public:
8  inline static Meta meta() {
9  Meta m("ipd", "std_unordered_map");
10  return m;
11  };
12 
14 
15  template<size_t N, typename T, typename U>
16  class IPDMap {
17  std::unordered_map<Array<N, T>, U> m_map;
18 
19  public:
20  inline IPDMap(size_t bucket_count, const Array<N, T>& empty) {}
21 
22  template<typename Updater>
23  inline U access(const Array<N, T>& key, Updater updater) {
24  auto& val = m_map[key];
25  updater(val);
26  return val;
27  }
28 
29  inline size_t size() const {
30  return m_map.size();
31  }
32 
33  template<typename F>
34  void for_all(F f) const {
35  for(auto& kv : m_map) {
36  const auto& key = kv.first;
37  const auto& val = kv.second;
38  f(key, val);
39  }
40  }
41  };
42  };
43 }}
Contains the text compression and encoding framework.
Definition: namespaces.hpp:11
Provides meta information about an Algorithm.
Definition: Meta.hpp:34
Algorithm(Algorithm const &)=default
IPDMap(size_t bucket_count, const Array< N, T > &empty)
U access(const Array< N, T > &key, Updater updater)
Interface for algorithms.
Definition: Algorithm.hpp:15