C++ design: How to cache most recent used

前端 未结 10 1407
走了就别回头了
走了就别回头了 2021-02-09 12:21

We have a C++ application for which we try to improve performance. We identified that data retrieval takes a lot of time, and want to cache data. We can\'t store all data in mem

10条回答
  •  我在风中等你
    2021-02-09 13:20

    Create a std:priority_queue::iterator>, with a comparer for the access stamp.. For an insert, first pop the last item off the queue, and erase it from the map. Than insert the new item into the map, and finally push it's iterator onto the queue.

提交回复
热议问题