Least Recently Used cache using C++

2019-01-22 09:42发布

I am trying to implement LRU Cache using C++ . I would like to know what is the best design for implementing them. I know LRU should provide find(), add an element and remove an element. The remove should remove the LRU element. what is the best ADTs to implement this For ex: If I use a map with element as value and time counter as key I can search in O(logn) time, Inserting is O(n), deleting is O(logn).

7条回答
别忘想泡老子
2楼-- · 2019-01-22 10:18

When you say priority, I think "heap" which naturally leads to increase-key and delete-min.

查看更多
登录 后发表回答