Namespace caches#

namespace caches

Typedefs

template<typename K, typename V>
using Pairs = typename std::list<std::pair<K, V>>::iterator
template<typename T>
class DequeCache

Subclassed by caches::FIFOCache< T >, caches::LIFOCache< T >

Public Functions

explicit DequeCache(size_t limit = 100)
virtual ~DequeCache() = default
virtual T next() const = 0
virtual T last() const = 0
virtual void push(T value) = 0
virtual void pop() = 0
virtual std::vector<T> slice(size_t width) const = 0
std::deque<T>::iterator begin()
std::deque<T>::iterator end()
std::deque<T>::const_iterator begin() const
std::deque<T>::const_iterator end() const
size_t size() const
size_t space() const
bool empty() const

Protected Attributes

size_t limit = 0
std::deque<T> cache
template<typename T>
class FIFOCache : public caches::DequeCache<T>

Public Functions

explicit FIFOCache(size_t limit = 100)
virtual T next() const override
virtual T last() const override
virtual void push(T value) override
virtual void pop() override
virtual std::vector<T> slice(size_t width) const override
template<typename T>
class LIFOCache : public caches::DequeCache<T>

Public Functions

explicit LIFOCache(size_t limit = 100)
virtual T next() const override
virtual T last() const override
virtual void push(T value) override
virtual void pop() override
virtual std::vector<T> slice(size_t width) const override
template<typename K, typename V>
class LRUCache

Public Functions

explicit LRUCache(size_t limit = 100)
size_t size() const
size_t space() const
V operator[](const K &key)
bool contains(const K &key) const
void store(const K &key, const V &value)

Private Members

size_t limit
std::list<std::pair<K, V>> list
std::unordered_map<K, Pairs<K, V>> map
template<typename K, typename V>
class StoreCache

Public Functions

explicit StoreCache(size_t limit = 100)
size_t size() const
size_t space() const
V &at(const K &key)
bool contains(const K &key) const
void store(const K &key, V &&value)

Protected Attributes

size_t limit
std::list<std::pair<K, V>> list
std::unordered_map<K, Pairs<K, V>> map