MatchDepository.hpp

A container for tag-based lookup, optimized for situations where tags are not removed from the lookup set.

template<typename Val, typename Metric, typename Selector, typename Regulator, size_t RawCacheSize = 0, size_t RegulatedCacheSize = 0>
class MatchDepository
#include <MatchDepository.hpp>

Public Types

using query_t = typename Metric::query_t
using tag_t = typename Metric::tag_t
using uid_t = size_t
using res_t = typename Selector::res_t
using adj_t = typename Regulator::adj_t
using set_t = typename Regulator::set_t
using view_t = typename Regulator::view_t

Public Functions

inline const Val &GetVal(const size_t uid) const

Access a reference to a single stored value by uid.

inline uid_t Put(const Val &v, const tag_t &t)

Store a value.

inline size_t GetSize() const

Get number of stored values.

inline void Clear()

Clear stored values.

inline void AdjRegulator(const uid_t uid, const adj_t amt)
inline void SetRegulator(const uid_t uid, const set_t set)
inline void SetRegulator(const uid_t uid, const Regulator &set)
inline const Regulator &GetRegulator(const uid_t uid)
inline const view_t &ViewRegulator(const uid_t uid) const
inline void DecayRegulator(const uid_t uid, const int steps = 1)

Apply decay to a regulator.

inline void DecayRegulators(const int steps = 1)

Apply decay to all regulators.

inline bool HasVal(const Val &val) const
inline uid_t GetUid(const Val &val) const
inline uid_t GetUid(const tag_t &tag) const

Private Functions

inline res_t DoRegulatedMatch(const query_t &query)

Perform matching with regulation.

inline res_t *DoRegulatedLookup(const query_t &query)

Return ptr to cached regulated result on success, nullptr on failure.

inline res_t DoRawMatch(const query_t &query)

Perform matching without regulation.

inline res_t *DoRawLookup(const query_t &query)

Return ptr to cached raw result on success, nullptr on failure.

inline void ClearCache()

Clear cached raw, regulated results.

Private Members

vector<internal::DepositoryEntry<Val, tag_t, Regulator>> data
SmallFifoMap<query_t, res_t, RawCacheSize> cache_raw
SmallFifoMap<query_t, res_t, RegulatedCacheSize> cache_regulated