首页 > 系统服务 > 详细

LRU Cache

时间:2015-09-26 21:07:37      阅读:287      评论:0      收藏:0      [点我收藏+]

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.

get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.
set(key, value) - Set or insert the value if the key is not already present. When the cache reached its capacity, it should invalidate the least recently used item before inserting a new item.

这是leetcode上的一道题,其实这是操作系统中的一种经典的算法。

 

LRU Cache

原文:http://www.cnblogs.com/qiaozhoulin/p/4841269.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!