template<typename K, typename V, exint(*)(const V &) SizeFunc = UTlruGetItemSize<V>, bool(*)(const V &) InUseFunc = UTlruGetItemInUse<V>, typename L = UT::RWNullLock>
class UT_LRUCache< K, V, SizeFunc, InUseFunc, L >
Definition at line 71 of file UT_LRUCache.h.
template<typename K, typename V, exint(*)(const V &) SizeFunc = UTlruGetItemSize<V>, bool(*)(const V &) InUseFunc = UTlruGetItemInUse<V>, typename L = UT::RWNullLock>
Construct a new LRU cache of a given max_size
. By default the cache is not thread-safe, but by setting the template argument L
to UT_RWLock
, the cache is automatically thread-safe. This incurs some overhead due to the locking, however, so only do that if absolutely required.
Definition at line 183 of file UT_LRUCache.h.
template<typename K, typename V, exint(*)(const V &) SizeFunc = UTlruGetItemSize<V>, bool(*)(const V &) InUseFunc = UTlruGetItemInUse<V>, typename L = UT::RWNullLock>
Returns an iterator to the front-most item in the LRU cache.
Definition at line 427 of file UT_LRUCache.h.
template<typename K, typename V, exint(*)(const V &) SizeFunc = UTlruGetItemSize<V>, bool(*)(const V &) InUseFunc = UTlruGetItemInUse<V>, typename L = UT::RWNullLock>
bool UT_LRUCache< K, V, SizeFunc, InUseFunc, L >::contains |
( |
const K & |
key | ) |
const |
|
inline |
Checks for the presence of the item with the given key
. Does not affect their ordering, like find
.
Definition at line 248 of file UT_LRUCache.h.
template<typename K, typename V, exint(*)(const V &) SizeFunc = UTlruGetItemSize<V>, bool(*)(const V &) InUseFunc = UTlruGetItemInUse<V>, typename L = UT::RWNullLock>
Returns the current size of the cache, in arbitrary units. If the cache is thread-safe this value may not be the most up-to-date.
Definition at line 221 of file UT_LRUCache.h.
template<typename K, typename V, exint(*)(const V &) SizeFunc = UTlruGetItemSize<V>, bool(*)(const V &) InUseFunc = UTlruGetItemInUse<V>, typename L = UT::RWNullLock>
bool UT_LRUCache< K, V, SizeFunc, InUseFunc, L >::erase |
( |
const K & |
key | ) |
|
|
inline |
Removes the item matching the key
. If the item existed and was successfully removed, then this function returns true
.
Definition at line 365 of file UT_LRUCache.h.
template<typename K, typename V, exint(*)(const V &) SizeFunc = UTlruGetItemSize<V>, bool(*)(const V &) InUseFunc = UTlruGetItemInUse<V>, typename L = UT::RWNullLock>
Find the item in the cache with the given key. If nothing is found then the iterator will point to the end. There's no const version, since looking up the key modifies the LRU cache's state and the iterator holds a read lock, if the cache is thread-safe.
- Note
- Since the iterator holds a lock, do
Definition at line 266 of file UT_LRUCache.h.
template<typename K, typename V, exint(*)(const V &) SizeFunc = UTlruGetItemSize<V>, bool(*)(const V &) InUseFunc = UTlruGetItemInUse<V>, typename L = UT::RWNullLock>
std::pair<iterator, bool> UT_LRUCache< K, V, SizeFunc, InUseFunc, L >::insert |
( |
const K & |
key, |
|
|
V && |
value, |
|
|
bool |
evict = false |
|
) |
| |
|
inline |
Insert a new item into the cache. The item is automatically marked as the most recently used. The cache is pruned beforehand, to avoid evicting the item immediately. Returns a pair of an iterator and a bool
. The iterator points to the item inserted, or the existing item if not evicted. The bool
value indicates whether the item got inserted or not.
Definition at line 297 of file UT_LRUCache.h.
template<typename K, typename V, exint(*)(const V &) SizeFunc = UTlruGetItemSize<V>, bool(*)(const V &) InUseFunc = UTlruGetItemInUse<V>, typename L = UT::RWNullLock>
Returns the current maximum size of the cache.
Definition at line 217 of file UT_LRUCache.h.
template<typename K, typename V, exint(*)(const V &) SizeFunc = UTlruGetItemSize<V>, bool(*)(const V &) InUseFunc = UTlruGetItemInUse<V>, typename L = UT::RWNullLock>
Sets the new maximum size for the cache. If the new maximum is smaller than the current maximum, the cache will be pruned to fit the new maximums size.
Definition at line 197 of file UT_LRUCache.h.
template<typename K, typename V, exint(*)(const V &) SizeFunc = UTlruGetItemSize<V>, bool(*)(const V &) InUseFunc = UTlruGetItemInUse<V>, typename L = UT::RWNullLock>
bool UT_LRUCache< K, V, SizeFunc, InUseFunc, L >::steal |
( |
const K & |
key, |
|
|
V && |
value |
|
) |
| |
|
inline |
Steals an item from the cache. This is functionally equivalent to erase
with a key, except the item in the cache also gets hoisted outside into value
, if it exists.
Definition at line 389 of file UT_LRUCache.h.
template<typename K, typename V, exint(*)(const V &) SizeFunc = UTlruGetItemSize<V>, bool(*)(const V &) InUseFunc = UTlruGetItemInUse<V>, typename L = UT::RWNullLock>
template<typename PROXIED , typename TYPE >