![]() |
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
|
#include <Cache.hpp>
Public Types | |
using | key_type = Key |
using | value_type = const Value * |
using | size_type = typename map_type::size_type |
Public Member Functions | |
Cache () | |
Cache (size_type max_size) | |
void | invalidate () |
Clear the cache. | |
bool | has (Key const &k) const |
Query if k is contained in the cache. | |
size_type | size () const |
Number of elements currently cached. | |
size_type | max_size () const |
Maximal size of the cache. | |
template<typename ValueRef > | |
Value const * | put (Key const &k, ValueRef &&v) |
Put a value into the cache. | |
template<typename KeyInputIterator , typename ValueInputIterator > | |
KeyInputIterator | put (KeyInputIterator kbegin, KeyInputIterator kend, ValueInputIterator vbegin) |
Put a range of values into the cache. | |
Value const * | get (Key const &k) const |
Get a value. | |
using Utils::Cache< Key, Value >::key_type = Key |
using Utils::Cache< Key, Value >::size_type = typename map_type::size_type |
using Utils::Cache< Key, Value >::value_type = const Value * |
|
inline |
|
inlineexplicit |
|
inline |
|
inline |
Query if k is contained in the cache.
Definition at line 98 of file Cache.hpp.
Referenced by Utils::Cache< Key, Value >::put().
|
inline |
|
inline |
Maximal size of the cache.
Definition at line 104 of file Cache.hpp.
Referenced by Utils::Cache< Key, Value >::put().
|
inline |
Put a value into the cache.
If the value already exists, it is overwritten. When the size of the cache would grow below the maximal size, a random element is removed before putting the new one.
Definition at line 112 of file Cache.hpp.
References Utils::Cache< Key, Value >::has().
Referenced by Utils::Cache< Key, Value >::put().
|
inline |
Put a range of values into the cache.
If the values already exists, it is overwritten. When the size of the cache would grow below the maximal size, a random elements are removed until all of the new values fit. If the given range is larger than max_size(), only the first max_size() elements are put into the cache.
KeyInputIterator | iterator of keys, at least InputIterator. |
ValueInputIterator | iterator of value, at least InputIterator. |
Definition at line 149 of file Cache.hpp.
References Utils::Cache< Key, Value >::max_size(), Utils::Cache< Key, Value >::put(), and Utils::Cache< Key, Value >::size().
|
inline |
Number of elements currently cached.
Definition at line 101 of file Cache.hpp.
Referenced by Utils::Cache< Key, Value >::put().