94 const Slab_&
find(Id_
id, Cfunction_ create, Pfunction_ populate) {
95 if (
id == my_last_id && my_last_slab) {
100 auto it = my_cache_exists.find(
id);
101 if (it != my_cache_exists.end()) {
102 auto chosen = it->second;
103 my_cache_data.splice(my_cache_data.end(), my_cache_data, chosen);
104 my_last_slab = &(chosen->first);
105 return chosen->first;
108 typename std::list<Element>::iterator location;
109 if (my_cache_data.size() < my_max_slabs) {
110 my_cache_data.emplace_back(create(),
id);
111 location = std::prev(my_cache_data.end());
113 location = my_cache_data.begin();
114 my_cache_exists.erase(location->second);
115 location->second = id;
116 my_cache_data.splice(my_cache_data.end(), my_cache_data, location);
118 my_cache_exists[id] = location;
120 auto& slab = location->first;
122 my_last_slab = &slab;