problemscpp
A collection of my answers to algorithm problems in c++.
|
#include <leetcode.h>
Public 成员函数 | |
LRUCache (int capacity) | |
以 正整数 作为容量 capacity 初始化 LRU 缓存 更多... | |
int | get (int key) |
如果关键字 key 存在于缓存中,则返回关键字的值,否则返回 -1 。 更多... | |
void | put (int key, int value) |
如果关键字 key 已经存在,则变更其数据值 value ;如果不存在,则向缓存中插入该组 key-value 。如果插入操作导致关键字数量超过 capacity ,则应该 逐出 最久未使用的关键字。 更多... | |
Private 属性 | |
int | capacity |
list< int > | keys |
unordered_map< int, int > | um |
在文件 leetcode.h 第 3284 行定义.
leetcode::lru_cache::LRUCache::LRUCache | ( | int | capacity | ) |
int leetcode::lru_cache::LRUCache::get | ( | int | key | ) |
如果关键字 key 存在于缓存中,则返回关键字的值,否则返回 -1 。
在文件 leetcode.cpp 第 9375 行定义.
引用了 acwing::acwing861::find(), keys , 以及 um.
void leetcode::lru_cache::LRUCache::put | ( | int | key, |
int | value | ||
) |
如果关键字 key 已经存在,则变更其数据值 value ;如果不存在,则向缓存中插入该组 key-value 。如果插入操作导致关键字数量超过 capacity ,则应该 逐出 最久未使用的关键字。
在文件 leetcode.cpp 第 9386 行定义.
引用了 capacity, acwing::acwing861::find(), keys , 以及 um.
|
private |
在文件 leetcode.h 第 3285 行定义.
被这些函数引用 put().
|
private |
在文件 leetcode.h 第 3286 行定义.
|
private |
在文件 leetcode.h 第 3287 行定义.