首页| JavaScript| HTML/CSS| Matlab| PHP| Python| Java| C/C++/VC++| C#| ASP| 其他|
购买积分 购买会员 激活码充值

您现在的位置是:虫虫源码 > C/C++/VC++ > 对于C++的LRU缓存

对于C++的LRU缓存

  • 资源大小:14.03 kB
  • 上传时间:2021-06-29
  • 下载次数:0次
  • 浏览次数:1次
  • 资源积分:1积分
  • 标      签: 缓存 LRU 对于

资 源 简 介

A C++ implementation of an LRU cache that has a maximum size (but no expiration time). The cache is implemented as a single hash table and provides fast, constant-time insertion, retrieval and query operations. Usage ``` #include #include "lru.hpp" using namespace std; int compute_value(int key) { return 100 + key; } int main() { // Create a cache that can hold 10 (int, int) pairs at most typedef plb::LRUCacheH4 lru_cache; lru_cache cache(10); // Insert a (key, value) pair into the cache: same syntax as std::map cache[1] = compute_value(1); for (int key = 1; key <= 2; ++key) { // Query the cache: Does it contain the key? lru_cache::const_iterator it = cache.find(key); if (it != cache.end()) { // Key found: retrieve its associated value cout << "retrieving: " << it.key() << " -> " << it.value() << end

文 件 列 表

lru-cache-cpp
lru.hpp
test

相 关 资 源

您 可 能 感 兴 趣 的

同 类 别 推 荐

VIP VIP