QCDLoop
One-loop scalar Feynman integrals
cache.h
1 //
2 // QCDLoop 2016
3 //
4 // Authors: Stefano Carrazza: stefano.carrazza@cern.ch
5 // Keith Ellis: keith.ellis@durham.ac.uk
6 // Giulia Zanderighi: giulia.zanderighi@cern.ch
7 
8 #pragma once
9 
10 #include <unordered_map>
11 #include <list>
12 #include <cstddef>
13 #include <stdexcept>
14 #include <vector>
15 #include "types.h"
16 using std::vector;
17 
18 namespace ql {
19 
23  template <typename TMass, typename TScale>
25  {
26  public:
28  size_t genkey(TScale const& mu2, vector<TMass> const& m, vector<TScale> const& p) const;
29  };
30 
36  template<typename Tkey, typename Tvalue>
37  class LRUCache
38  {
39  public:
44  LRUCache(int const& size = 1);
45  LRUCache(const LRUCache &obj);
46  ~LRUCache();
47 
48  typedef typename std::pair<Tkey, Tvalue> key_value_pair_t;
49  typedef typename std::list<key_value_pair_t>::iterator list_iterator_t;
50 
52  void setCacheSize(int const& size);
53 
55  int const& getCacheSize() const { return _size; }
56 
58  void store(Tkey const& key, Tvalue const& value);
59 
61  bool get(Tkey const& key, Tvalue & out);
62 
63  private:
64  int _size;
65  std::list<key_value_pair_t> _cache_list;
66  std::unordered_map<Tkey, list_iterator_t> _cache_map;
67  };
68 }
LRUCache(int const &size=1)
LRUCache constructor.
Definition: cache.cc:78
The Hasher algorithm container for key generation.
Definition: cache.h:24
void setCacheSize(int const &size)
Set the Cache size.
Definition: cache.cc:97
void store(Tkey const &key, Tvalue const &value)
Store the cached data.
Definition: cache.cc:105
The LRU Cache class.
Definition: cache.h:37
Definition: box.cc:14
int const & getCacheSize() const
Get the Cache size.
Definition: cache.h:55