2 #ifndef __PCL_OUTOFCORE_LRU_CACHE__
3 #define __PCL_OUTOFCORE_LRU_CACHE__
29 template<
typename KeyT,
typename CacheItemT>
37 using Cache = std::map<KeyT, std::pair<CacheItemT, typename KeyIndex::iterator> >;
57 assert(it !=
cache_.end ());
63 return it->second.first;
71 assert(it !=
cache_.end ());
79 insert (
const KeyT& key,
const CacheItemT& value)
87 std::size_t size =
size_;
88 std::size_t item_size = value.sizeOf ();
99 std::size_t tail_timestamp = cache_it->second.first.timestamp;
100 std::size_t tail_size = cache_it->second.first.sizeOf ();
103 if (value.timestamp == tail_timestamp)
122 cache_.insert (std::make_pair (key, std::make_pair (value, it)));
137 return it->second.first;
143 return value.sizeOf ();
150 for (
int i=0; i < item_count; i++)
157 assert(it !=
cache_.end());
160 size_ -= it->second.first.sizeOf ();
181 #endif //__PCL_OUTOFCORE_LRU_CACHE__