Home | History | Annotate | Download | only in utils

Lines Matching defs:Entry

59     struct Entry {
62 Entry* parent;
63 Entry* child;
65 Entry(TKey key_, TValue value_) : key(key_), value(value_), parent(NULL), child(NULL) {
70 struct HashForEntry : public std::unary_function<Entry*, hash_t> {
71 size_t operator() (const Entry* entry) const {
72 return hash_type(entry->key);
76 struct EqualityForHashedEntries : public std::unary_function<Entry*, hash_t> {
77 bool operator() (const Entry* lhs, const Entry* rhs) const {
82 typedef std::unordered_set<Entry*, HashForEntry, EqualityForHashedEntries> LruCacheSet;
84 void attachToCache(Entry& entry);
85 void detachFromCache(Entry& entry);
88 Entry entryForSearch(key, mNullValue);
95 Entry* mOldest;
96 Entry* mYoungest;
174 Entry *entry = *find_result;
175 detachFromCache(*entry);
176 attachToCache(*entry);
177 return entry->value;
190 Entry* newEntry = new Entry(key, value);
202 Entry* entry = *find_result;
203 mSet->erase(entry);
205 (*mListener)(entry->key, entry->value);
207 detachFromCache(*entry);
208 delete entry;
232 for (Entry* p = mOldest; p != NULL; p = p->child) {
238 for (auto entry : *mSet.get()) {
239 delete entry;
245 void LruCache<TKey, TValue>::attachToCache(Entry& entry) {
247 mYoungest = mOldest = &entry;
249 entry.parent = mYoungest;
250 mYoungest->child = &entry;
251 mYoungest = &entry;
256 void LruCache<TKey, TValue>::detachFromCache(Entry& entry) {
257 if (entry.parent != NULL) {
258 entry.parent->child = entry.child;
260 mOldest = entry.child;
262 if (entry.child != NULL) {
263 entry.child->parent = entry.parent;
265 mYoungest = entry.parent;
268 entry.parent = NULL;
269 entry.child = NULL;