![]() |
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 >::size_type = typename map_type::size_type |
|
inlineexplicit |
Query if k is contained in the cache.
Definition at line 97 of file Cache.hpp.
Referenced by Utils::Cache< Key, Value >::put().
|
inline |
Maximal size of the cache.
Definition at line 103 of file Cache.hpp.
Referenced by Utils::Cache< Key, Value >::put().
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 111 of file Cache.hpp.
References Utils::Cache< Key, Value >::has(), and stream.
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 148 of file Cache.hpp.
References Utils::Cache< Key, Value >::max_size(), Utils::Cache< Key, Value >::put(), Utils::Cache< Key, Value >::size(), and stream.
|
inline |
Number of elements currently cached.
Definition at line 100 of file Cache.hpp.
Referenced by Utils::Cache< Key, Value >::put().