Least Recently Used cache using C++

前端 未结 7 1312
甜味超标
甜味超标 2020-12-14 05:04

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 remov

7条回答
  •  一个人的身影
    2020-12-14 05:20

    I'd go with a normal heap in C++.

    With the std::make_heap (guaranteed by the standard to be O(n)), std::pop_heap, and std::push_heap in #include, implementing it would be absolutely cake. You only have to worry about increase-key.

提交回复
热议问题