Krita Source Code Documentation
Loading...
Searching...
No Matches
KisRotatingCache< Key, Value, CacheSize > Class Template Reference

#include <KisRotatingCache.h>

Public Types

using CacheItem = std::pair<Key, Value>
 

Public Member Functions

void clear ()
 
std::optional< Value > find (const Key &key) const
 
void push (Key key, Value value)
 

Private Attributes

boost::container::static_vector< CacheItem, CacheSize > m_storage
 

Detailed Description

template<typename Key, typename Value, size_t CacheSize>
class KisRotatingCache< Key, Value, CacheSize >

Definition at line 19 of file KisRotatingCache.h.

Member Typedef Documentation

◆ CacheItem

template<typename Key , typename Value , size_t CacheSize>
using KisRotatingCache< Key, Value, CacheSize >::CacheItem = std::pair<Key, Value>

Definition at line 22 of file KisRotatingCache.h.

Member Function Documentation

◆ clear()

template<typename Key , typename Value , size_t CacheSize>
void KisRotatingCache< Key, Value, CacheSize >::clear ( )
inline

Definition at line 40 of file KisRotatingCache.h.

40 {
41 m_storage.clear();
42 }
boost::container::static_vector< CacheItem, CacheSize > m_storage

References KisRotatingCache< Key, Value, CacheSize >::m_storage.

◆ find()

template<typename Key , typename Value , size_t CacheSize>
std::optional< Value > KisRotatingCache< Key, Value, CacheSize >::find ( const Key & key) const
inline

Definition at line 31 of file KisRotatingCache.h.

31 {
32 for (auto it = m_storage.begin(); it != m_storage.end(); ++it) {
33 if (it->first == key) {
34 return it->second;
35 }
36 }
37 return std::nullopt;
38 }

References KisRotatingCache< Key, Value, CacheSize >::m_storage.

◆ push()

template<typename Key , typename Value , size_t CacheSize>
void KisRotatingCache< Key, Value, CacheSize >::push ( Key key,
Value value )
inline

Definition at line 24 of file KisRotatingCache.h.

24 {
25 if (m_storage.size() == m_storage.max_size()) {
26 m_storage.erase(m_storage.begin());
27 }
28 m_storage.emplace_back(std::move(key), std::move(value));
29 }
float value(const T *src, size_t ch)

References KisRotatingCache< Key, Value, CacheSize >::m_storage, and value().

Member Data Documentation

◆ m_storage

template<typename Key , typename Value , size_t CacheSize>
boost::container::static_vector<CacheItem, CacheSize> KisRotatingCache< Key, Value, CacheSize >::m_storage
private

Definition at line 45 of file KisRotatingCache.h.


The documentation for this class was generated from the following file: