5#ifndef EVENTCONTAINERS_IDENTIFIABLEVALUECACHE_H
6#define EVENTCONTAINERS_IDENTIFIABLEVALUECACHE_H
64 std::vector<std::pair<size_t, T>>
getAll()
const;
69 std::vector<std::atomic<T>>
m_vec;
74std::vector<std::pair<size_t, T>>
76 std::vector<std::pair<size_t, T>> list;
77 for(
size_t i =0; i<
m_vec.size(); i++){
78 T item =
m_vec[i].load(std::memory_order_relaxed);
79 if(item!=
m_emptyValue) list.emplace_back(i, std::move(item));
92 return m_vec.at(i).compare_exchange_strong(val, value);
std::true_type thread_safe
IdentifiableValueCache(const IdentifiableValueCache &)=delete
~IdentifiableValueCache()=default
const std::vector< std::atomic< T > > & rawReadAccess() const
T retrieve(size_t i)
Retrieve the Value stored in that hash.
const T & emptyValue() const
Return the empty value that is interpreted as an empty entry.
IdentifiableValueCache(size_t maxSize, T emptyValuein)
Pass the maximum hash to size the cache and the defaultValue which will be interpreted as an empty va...
std::vector< std::atomic< IDCInDetBSErrContainer::ErrorCode > > m_vec
T retrieve(size_t i) const
As above, but no cache extension.
bool present(size_t i) const
As above, but no cache extension.
std::vector< std::pair< size_t, T > > getAll() const
Make a vector of hashes and values, convenient for iteration and other uses.
const IDCInDetBSErrContainer::ErrorCode m_emptyValue
bool present(size_t i)
Returns true if the value is set to anything but the emptyValue.
void forceReset()
Forceable empty the container, DO NOT USE THIS IN MT ENVIRONMENT.
bool setOrDrop(size_t i, const T &value)
Set the given hash to the value.