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