|
ATLAS Offline Software
|
Go to the documentation of this file.
14 #ifndef CXXUTILS_CONCURRENTSTRTOVALMAP_H
15 #define CXXUTILS_CONCURRENTSTRTOVALMAP_H
22 #include "boost/iterator/iterator_facade.hpp"
23 #include "boost/range/iterator_range.hpp"
25 #include <type_traits>
84 template <
class VALUE,
template <
class>
class UPDATER>
118 const Context_t& ctx = Updater_t::defaultContext());
133 size_t capacity = 64,
134 const Context_t& ctx = Updater_t::defaultContext());
149 template <
class InputIterator>
154 const Context_t& ctx = Updater_t::defaultContext());
203 class const_iterator;
217 :
public boost::iterator_facade<const_iterator,
218 const const_iterator_value,
219 std::bidirectional_iterator_tag,
220 const const_iterator_value>
247 friend class boost::iterator_core_access;
300 :
public boost::iterator_facade<iterator,
301 const iterator_value,
302 std::bidirectional_iterator_tag,
303 const iterator_value>
323 friend class boost::iterator_core_access;
391 const_iterator
end()
const;
492 std::pair<const_iterator, const_iterator>
506 std::pair<iterator, iterator>
521 std::pair<const_iterator, bool>
523 const Context_t& ctx = Updater_t::defaultContext());
537 std::pair<const_iterator, bool>
539 const Context_t& ctx = Updater_t::defaultContext());
553 std::pair<const_iterator, bool>
555 const Context_t& ctx = Updater_t::defaultContext());
569 std::pair<const_iterator, bool>
571 const Context_t& ctx = Updater_t::defaultContext());
585 std::pair<const_iterator, bool>
587 const Context_t& ctx = Updater_t::defaultContext());
601 std::pair<const_iterator, bool>
603 const Context_t& ctx = Updater_t::defaultContext());
618 template <
class PAIR>
619 std::pair<const_iterator, bool>
insert (
const PAIR&
p,
620 const Context_t& ctx = Updater_t::defaultContext());
635 template <
class PAIR>
636 std::pair<const_iterator, bool>
insert (PAIR&&
p,
637 const Context_t& ctx = Updater_t::defaultContext());
649 template <
class InputIterator>
651 const Context_t& ctx = Updater_t::defaultContext());
663 const Context_t& ctx = Updater_t::defaultContext());
753 std::pair<const_iterator, bool>
755 std::unique_ptr<mapped_type>
val,
756 const Context_t& ctx = Updater_t::defaultContext());
770 size_t operator() (
const std::string&
s)
const;
797 #endif // not CXXUTILS_CONCURRENTSTRTOVALMAP_H
JetConstituentVector::iterator iterator
std::pair< const_iterator, const_iterator > equal_range(const key_type &key) const
Return a range of iterators with entries matching key.
void increment()
iterator_facade requirement: Increment the iterator.
const mapped_type & at(const key_type &key) const
Look up an element in the map.
ConcurrentStrToValMap(ConcurrentStrToValMap &&other)=delete
bool equal(const iterator &other) const
iterator_facade requirement: Equality test.
const_iterator cend() const
Iterator at the end of the map.
uintptr_t ConcurrentHashmapVal_t
Type used for keys and values — an unsigned big enough to hold a pointer.
iterator(typename Impl_t::const_iterator it)
Constructor.
Impl_t m_impl
The underlying hash table.
void swap(ConcurrentStrToValMap &other)
Swap this container with another.
const_iterator find(const key_type &key) const
Look up an element in the map.
Concept check for Updater class used by concurrent classes.
Impl_t::const_iterator m_impl
The iterator on the underlying table.
const_iterator(const iterator &other)
Conversion from non-const iterator (for interoperability).
ConcurrentStrToValMap(Updater_t &&updater, size_type capacity=64, const Context_t &ctx=Updater_t::defaultContext())
Constructor.
const iterator_value dereference() const
iterator_facade requirement: Dereference the iterator.
std::pair< const_iterator, bool > emplace(const key_type &key, mapped_type &&val, const Context_t &ctx=Updater_t::defaultContext())
Add an element to the map.
std::string key_type
Standard STL types.
std::pair< const_iterator, bool > emplace(key_type &&key, mapped_type &&val, const Context_t &ctx=Updater_t::defaultContext())
Add an element to the map.
typename Impl_t::Updater_t Updater_t
Updater object.
void decrement()
iterator_facade requirement: Decrement the iterator.
bool contains(const key_type &key) const
Test if a key is in the container.
Hash functional for keys.
void rehash(size_type capacity)
Increase the table capacity.
static const std::string * keyAsString(val_t val)
Convert an underlying key value to a string pointer.
iterator end()
Iterator at the end of the map.
mapped_type & at(const key_type &key)
Look up an element in the map.
Impl_t::const_iterator get(const key_type &key) const
Do a lookup in the table.
const_iterator begin() const
Iterator at the start of the map.
void increment()
iterator_facade requirement: Increment the iterator.
std::pair< const_iterator, bool > emplace(key_type &&key, const mapped_type &val, const Context_t &ctx=Updater_t::defaultContext())
Add an element to the map.
bool valid() const
Test if this iterator is valid.
CxxUtils::detail::ConcurrentHashmapVal_t val_t
Representation type in the underlying map.
const_iterator(typename Impl_t::const_iterator it)
Constructor.
std::pair< const key_type &, const mapped_type & > const_iterator_value
Value structures for iterators.
bool empty() const
Test if the map is currently empty.
const_iterator end() const
Iterator at the end of the map.
static mapped_type * mappedAsMapped(val_t val)
Convert an underlying mapped value a pointer to this type's mapped value.
Updater_t & updater()
Access the Updater instance.
void decrement()
iterator_facade requirement: Decrement the iterator.
const_iterator cbegin() const
Iterator at the start of the map.
Matching functional for keys.
static val_t mappedAsVal(mapped_type *val)
Convert this type's mapped value to an underlying mapped value.
~ConcurrentStrToValMap()
Destructor.
ConcurrentStrToValMap(InputIterator f, InputIterator l, Updater_t &&updater, size_type capacity=64, const Context_t &ctx=Updater_t::defaultContext())
Constructor from a range.
Helpers for converting between uintptr_t and a pointer or integer.
boost::iterator_range< const_iterator > const_iterator_range
A range defined by two iterators.
bool equal(const iterator &other) const
iterator_facade requirement: Equality test.
std::pair< const key_type, mapped_type & > iterator_value
Hash map from strings to arbitrary objects allowing concurrent, lockless reads.
size_type count(const key_type &key) const
Return the number of times a given key is in the container.
iterator_range range()
Return an iterator range covering the entire map.
bool equal(const const_iterator &other) const
iterator_facade requirement: Equality test.
ConcurrentStrToValMap(const ConcurrentStrToValMap &other, Updater_t &&updater, size_t capacity=64, const Context_t &ctx=Updater_t::defaultContext())
Constructor from another map.
size_t capacity() const
Return the current size (capacity) of the hash table.
std::pair< iterator, iterator > equal_range(const key_type &key)
Return a range of iterators with entries matching key.
Impl_t::const_iterator m_impl
The iterator on the underlying table.
std::pair< const_iterator, bool > emplace(const key_type &key, std::unique_ptr< mapped_type > val, const Context_t &ctx=Updater_t::defaultContext())
Add an element to the map.
bool valid() const
Test if this iterator is valid.
std::pair< const_iterator, bool > emplace(const key_type &key, const mapped_type &val, const Context_t &ctx=Updater_t::defaultContext())
Add an element to the map.
std::pair< const_iterator, bool > put(std::unique_ptr< key_type > key, std::unique_ptr< mapped_type > val, const Context_t &ctx=Updater_t::defaultContext())
Insert an entry in the table.
iterator find(const key_type &key)
Look up an element in the map.
Compatibility helpers for using some pieces of C++20 concepts with older compilers.
iterator begin()
Iterator at the start of the map.
void quiescent(const Context_t &ctx)
Called when this thread is no longer referencing anything from this container.
void insert(InputIterator first, InputIterator last, const Context_t &ctx=Updater_t::defaultContext())
Insert a range of elements to the map.
void reserve(size_type capacity, const Context_t &ctx=Updater_t::defaultContext())
Increase the table capacity.
bool equal(const const_iterator &other) const
iterator_facade requirement: Equality test.
ATH_REQUIRES(detail::IsConcurrentHashmapPayload< KEY > &&detail::IsConcurrentHashmapPayload< VALUE > &&detail::IsUpdater< UPDATER > &&detail::IsHash< HASHER, KEY > &&detail::IsBinaryPredicate< MATCHER, KEY >) class ConcurrentMap
Hash map from integers/pointers allowing concurrent, lockless reads.
const const_iterator_value dereference() const
iterator_facade requirement: Dereference the iterator.
static val_t keyAsVal(const std::string *s)
Convert a string pointer to an underlying key value.
std::pair< const_iterator, bool > emplace(key_type &&key, std::unique_ptr< mapped_type > val, const Context_t &ctx=Updater_t::defaultContext())
Add an element to the map.
std::hash< std::string > m_hash
Hash functional.
typename detail::ConcurrentHashmapImpl< CxxUtils::SimpleUpdater, Hasher, Matcher > Impl_t
size_type size() const
Return the number of items currently in the map.
typename Updater_t::Context_t Context_t
Context type.
boost::iterator_range< iterator > iterator_range
const_iterator_range range() const
Return an iterator range covering the entire map.
std::pair< const_iterator, bool > insert(PAIR &&p, const Context_t &ctx=Updater_t::defaultContext())
Add an element to the map.
ConcurrentStrToValMap(const ConcurrentStrToValMap &other)=delete
Copy / move / assign not supported.
std::pair< const_iterator, bool > insert(const PAIR &p, const Context_t &ctx=Updater_t::defaultContext())
Add an element to the map.
Hash table allowing concurrent, lockless reads.