10 #ifndef YAPF_COSTCACHE_HPP
11 #define YAPF_COSTCACHE_HPP
13 #include "../../timer/timer_game_calendar.h"
20 template <
class Types>
24 typedef typename Types::Tpf
Tpf;
25 typedef typename Types::NodeList::Titem
Node;
65 template <
class Tsegment>
67 static const int C_HASH_BITS = 14;
70 using Heap = std::deque<Tsegment>;
71 typedef typename Tsegment::Key
Key;
85 inline Tsegment &Get(
Key &key,
bool *found)
87 Tsegment *item = m_map.
Find(key);
88 if (item ==
nullptr) {
90 item = &m_heap.emplace_back(key);
104 template <
class Types>
107 typedef typename Types::Tpf
Tpf;
108 typedef typename Types::NodeList::Titem
Node;
109 typedef typename Node::Key
Key;
110 typedef typename Node::CachedData CachedData;
111 typedef typename CachedData::Key CacheKey;
113 using LocalCache = std::deque<CachedData>;
116 Cache &m_global_cache;
117 LocalCache m_local_cache;
124 return *
static_cast<Tpf *
>(
this);
127 inline static Cache &stGetGlobalCache()
129 static int last_rail_change_counter = 0;
147 CacheKey key(n.GetKey());
149 if (!
Yapf().CanUseGlobalCache(n)) {
150 Yapf().ConnectNodeToCachedData(n, m_local_cache.emplace_back(key));
155 CachedData &item = m_global_cache.Get(key, &found);
156 Yapf().ConnectNodeToCachedData(n, item);