OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::cache_set< K, H > Class Template Reference

Thread-safe set with a maximum size. More...

#include <cache_set.hpp>

Inheritance diagram for cbdc::cache_set< K, H >:

Public Member Functions

 cache_set ()=delete
 
 cache_set (size_t max_size)
 Constructor.
 
template<typename T >
auto add (T &&val) -> bool
 Adds a value to the set, evicting the oldest value if the set is full.
 
auto contains (const K &val) const -> bool
 Determines whether a given value is present in the cache set.
 

Detailed Description

template<typename K, typename H = std::hash<K>>
class cbdc::cache_set< K, H >

Thread-safe set with a maximum size.

If full, inserting a new value will evict the oldest value.

Template Parameters
Ktype of the values in the set.
Hhasher compatible with std::unordered_set.

Definition at line 21 of file cache_set.hpp.

Constructor & Destructor Documentation

◆ cache_set() [1/2]

template<typename K , typename H = std::hash<K>>
cbdc::cache_set< K, H >::cache_set ( )
delete

◆ cache_set() [2/2]

template<typename K , typename H = std::hash<K>>
cbdc::cache_set< K, H >::cache_set ( size_t max_size)
inlineexplicit

Constructor.

Parameters
max_sizemaximum number of elements in the set.

Definition at line 27 of file cache_set.hpp.

Member Function Documentation

◆ add()

template<typename K , typename H = std::hash<K>>
template<typename T >
auto cbdc::cache_set< K, H >::add ( T && val) -> bool
inline

Adds a value to the set, evicting the oldest value if the set is full.

Parameters
valvalue to add.
Returns
true if the value was not already in the set.

Definition at line 38 of file cache_set.hpp.

◆ contains()

template<typename K , typename H = std::hash<K>>
auto cbdc::cache_set< K, H >::contains ( const K & val) const -> bool
inlinenodiscard

Determines whether a given value is present in the cache set.

Parameters
valvalue to check.
Returns
true if the value is present in the set.

Definition at line 56 of file cache_set.hpp.


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