problemscpp
A collection of my answers to algorithm problems in c++.
|
#include <leetcode.h>
Public 成员函数 | |
LFUCache (int capacity) | |
用数据结构的容量 capacity 初始化对象 更多... | |
int | get (int key) |
如果键 key 存在于缓存中,则获取键的值,否则返回 -1 。 更多... | |
void | put (int key, int value) |
如果键 key 已存在,则变更其值;如果键不存在,请插入键值对。当缓存达到其容量 capacity 时,则应该在插入新项之前,移除最不经常使用的项。在此问题中,当存在平局(即两个或更多个键具有相同使用频率)时,应该去除 最近最久未使用 的键。 更多... | |
Private 属性 | |
int | capacity |
unordered_map< int, int > | cnt |
map< int, list< int > > | tnc |
unordered_map< int, int > | um |
在文件 leetcode.h 第 3373 行定义.
|
inline |
int leetcode::lfu_cache::LFUCache::get | ( | int | key | ) |
如果键 key 存在于缓存中,则获取键的值,否则返回 -1 。
在文件 leetcode.cpp 第 9434 行定义.
引用了 capacity, cnt, acwing::acwing861::find(), tnc , 以及 um.
被这些函数引用 leetcode::lfu_cache::TEST().
void leetcode::lfu_cache::LFUCache::put | ( | int | key, |
int | value | ||
) |
如果键 key 已存在,则变更其值;如果键不存在,请插入键值对。当缓存达到其容量 capacity 时,则应该在插入新项之前,移除最不经常使用的项。在此问题中,当存在平局(即两个或更多个键具有相同使用频率)时,应该去除 最近最久未使用 的键。
在文件 leetcode.cpp 第 9455 行定义.
引用了 capacity, cnt, acwing::acwing861::find(), tnc , 以及 um.
被这些函数引用 leetcode::lfu_cache::TEST().
|
private |
在文件 leetcode.h 第 3377 行定义.
|
private |
在文件 leetcode.h 第 3375 行定义.
|
private |
在文件 leetcode.h 第 3376 行定义.
|
private |
在文件 leetcode.h 第 3374 行定义.