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