#include <lru_cache.h>

Public Types | |
| using | EvictionPredicate = std::function<bool(const Key&)> |
Public Member Functions | |
| LruCache (size_t capacity) | |
| Value * | Insert (const Key &key, Value value) |
| Value * | Get (const Key &key) |
| Value * | Peek (const Key &key) |
| bool | Contains (const Key &key) const |
| void | Touch (const Key &key) |
| bool | Erase (const Key &key) |
| void | Rename (const Key &old_key, const Key &new_key) |
| void | Clear () |
| size_t | Size () const |
| size_t | Capacity () const |
| bool | Empty () const |
| void | SetCapacity (size_t capacity) |
| void | SetEvictionPredicate (EvictionPredicate pred) |
| template<typename Fn > | |
| void | ForEach (Fn &&fn) |
| template<typename Fn > | |
| void | ForEach (Fn &&fn) const |
| const std::map< Key, Value > & | entries () const |
| std::map< Key, Value > & | mutable_entries () |
| const std::deque< Key > & | lru_order () const |
Private Member Functions | |
| void | RemoveFromLru (const Key &key) |
| void | EvictIfNeeded () |
Private Attributes | |
| size_t | capacity_ |
| std::map< Key, Value > | entries_ |
| std::deque< Key > | lru_ |
| EvictionPredicate | eviction_predicate_ |
Definition at line 33 of file lru_cache.h.
| using yaze::util::LruCache< Key, Value >::EvictionPredicate = std::function<bool(const Key&)> |
Definition at line 35 of file lru_cache.h.
|
inlineexplicit |
Definition at line 37 of file lru_cache.h.
|
inline |
Definition at line 41 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::entries_, yaze::util::LruCache< Key, Value >::Erase(), yaze::util::LruCache< Key, Value >::EvictIfNeeded(), and yaze::util::LruCache< Key, Value >::lru_.

|
inline |
Definition at line 51 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::entries_, and yaze::util::LruCache< Key, Value >::Touch().

|
inline |
Definition at line 59 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::entries_.
|
inline |
Definition at line 66 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::entries_.
|
inline |
Definition at line 71 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::lru_, and yaze::util::LruCache< Key, Value >::RemoveFromLru().
Referenced by yaze::util::LruCache< Key, Value >::Get().

|
inline |
Definition at line 77 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::entries_, and yaze::util::LruCache< Key, Value >::RemoveFromLru().
Referenced by yaze::util::LruCache< Key, Value >::Insert(), and yaze::util::LruCache< Key, Value >::Rename().

|
inline |
Definition at line 85 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::entries_, yaze::util::LruCache< Key, Value >::Erase(), yaze::util::LruCache< Key, Value >::lru_, and yaze::util::LruCache< Key, Value >::RemoveFromLru().

|
inline |
Definition at line 96 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::entries_, and yaze::util::LruCache< Key, Value >::lru_.
|
inline |
Definition at line 101 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::entries_.
|
inline |
Definition at line 102 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::capacity_.
|
inline |
Definition at line 103 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::entries_.
|
inline |
Definition at line 105 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::capacity_, and yaze::util::LruCache< Key, Value >::EvictIfNeeded().

|
inline |
Definition at line 112 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::eviction_predicate_.
|
inline |
Definition at line 118 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::entries_.
|
inline |
Definition at line 125 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::entries_.
|
inline |
Definition at line 132 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::entries_.
|
inline |
Definition at line 133 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::entries_.
|
inline |
Definition at line 136 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::lru_.
|
inlineprivate |
Definition at line 139 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::lru_.
Referenced by yaze::util::LruCache< Key, Value >::Erase(), yaze::util::LruCache< Key, Value >::Rename(), and yaze::util::LruCache< Key, Value >::Touch().
|
inlineprivate |
Definition at line 143 of file lru_cache.h.
References yaze::util::LruCache< Key, Value >::capacity_, yaze::util::LruCache< Key, Value >::entries_, yaze::util::LruCache< Key, Value >::eviction_predicate_, and yaze::util::LruCache< Key, Value >::lru_.
Referenced by yaze::util::LruCache< Key, Value >::Insert(), and yaze::util::LruCache< Key, Value >::SetCapacity().
|
private |
Definition at line 160 of file lru_cache.h.
Referenced by yaze::util::LruCache< Key, Value >::Capacity(), yaze::util::LruCache< Key, Value >::EvictIfNeeded(), and yaze::util::LruCache< Key, Value >::SetCapacity().
|
private |
Definition at line 161 of file lru_cache.h.
Referenced by yaze::util::LruCache< Key, Value >::Clear(), yaze::util::LruCache< Key, Value >::Contains(), yaze::util::LruCache< Key, Value >::Empty(), yaze::util::LruCache< Key, Value >::entries(), yaze::util::LruCache< Key, Value >::Erase(), yaze::util::LruCache< Key, Value >::EvictIfNeeded(), yaze::util::LruCache< Key, Value >::ForEach(), yaze::util::LruCache< Key, Value >::ForEach(), yaze::util::LruCache< Key, Value >::Get(), yaze::util::LruCache< Key, Value >::Insert(), yaze::util::LruCache< Key, Value >::mutable_entries(), yaze::util::LruCache< Key, Value >::Peek(), yaze::util::LruCache< Key, Value >::Rename(), and yaze::util::LruCache< Key, Value >::Size().
|
private |
Definition at line 162 of file lru_cache.h.
Referenced by yaze::util::LruCache< Key, Value >::Clear(), yaze::util::LruCache< Key, Value >::EvictIfNeeded(), yaze::util::LruCache< Key, Value >::Insert(), yaze::util::LruCache< Key, Value >::lru_order(), yaze::util::LruCache< Key, Value >::RemoveFromLru(), yaze::util::LruCache< Key, Value >::Rename(), and yaze::util::LruCache< Key, Value >::Touch().
|
private |
Definition at line 163 of file lru_cache.h.
Referenced by yaze::util::LruCache< Key, Value >::EvictIfNeeded(), and yaze::util::LruCache< Key, Value >::SetEvictionPredicate().