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) {}
37 Entry* node = fLRU.
head();
54 Entry* entry = *
value;
55 if (entry != fLRU.
head()) {
59 return &entry->fValue;
65 Entry* entry =
new Entry(
key, std::move(
value));
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);
98 for (Entry* e = fLRU.
head(); e; e = fLRU.
head()) {
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)
T * init(const SkTInternalLList &list, IterStart startLoc)
void remove(const K &key)
T * find(const K &key) const
T __attribute__((ext_vector_type(N))) V