8#ifndef SkLRUCache_DEFINED
9#define SkLRUCache_DEFINED
18template <
typename K,
typename V,
typename HashK = SkGoodHash>
24 , fValue(std::move(
value)) {}
33 explicit SkLRUCache(
int maxCount) : fMaxCount(maxCount) {}
55 if (entry != fLRU.
head()) {
59 return &entry->fValue;
68 while (fMap.
count() > fMaxCount) {
69 this->remove(fLRU.
tail()->fKey);
71 return &entry->fValue;
75 if (
V* found = this->
find(key)) {
76 *found = std::move(
value);
87 template <
typename Fn>
88 void foreach(Fn&& fn) {
92 fn(&
e->fKey, &
e->fValue);
106 static const K& GetKey(
Entry*
e) {
110 static uint32_t
Hash(
const K& k) {
115 void remove(
const K&
key) {
#define SK_DECLARE_INTERNAL_LLIST_INTERFACE(ClassName)
SkLRUCache(const SkLRUCache &)=delete
SkLRUCache & operator=(const SkLRUCache &)=delete
V * insert_or_update(const K &key, V value)
V * insert(const K &key, V value)
void remove(const K &key)
T * find(const K &key) const
T __attribute__((ext_vector_type(N))) V
static uint32_t Hash(uint32_t key)