14 #ifndef CXXUTILS_CONCURRENTSTRTOVALMAP_H 
   15 #define CXXUTILS_CONCURRENTSTRTOVALMAP_H 
   22 #include "boost/iterator/iterator_facade.hpp" 
   24 #include <type_traits> 
   83 template <
class VALUE, 
template <
class> 
class UPDATER>
 
   84 requires (detail::IsUpdater<UPDATER>)
 
   85 class ConcurrentStrToValMap
 
   91   using Impl_t = 
typename detail::ConcurrentHashmapImpl<UPDATER, Hasher, Matcher>;
 
   98   using key_type = std::string;
 
   99   using mapped_type = 
VALUE;
 
  100   using size_type = size_t;
 
  102   using Updater_t = 
typename Impl_t::Updater_t;
 
  104   using Context_t = 
typename Updater_t::Context_t;
 
  115   ConcurrentStrToValMap (Updater_t&& updater,
 
  116                          size_type capacity = 64,
 
  117                          const Context_t& ctx = Updater_t::defaultContext());
 
  130   ConcurrentStrToValMap (
const ConcurrentStrToValMap& 
other,
 
  132                          size_t capacity = 64,
 
  133                          const Context_t& ctx = Updater_t::defaultContext());
 
  148   template <
class InputIterator>
 
  149   ConcurrentStrToValMap (InputIterator 
f,
 
  152                          size_type capacity = 64,
 
  153                          const Context_t& ctx = Updater_t::defaultContext());
 
  157   ConcurrentStrToValMap (
const ConcurrentStrToValMap& 
other) = 
delete;
 
  158   ConcurrentStrToValMap (ConcurrentStrToValMap&& 
other) = 
delete;
 
  159   ConcurrentStrToValMap& 
operator= (
const ConcurrentStrToValMap& 
other) = 
delete;
 
  160   ConcurrentStrToValMap& 
operator= (ConcurrentStrToValMap&& 
other) = 
delete;
 
  166   ~ConcurrentStrToValMap();
 
  172   size_type 
size() 
const;
 
  184   size_t capacity() 
const;
 
  199   using const_iterator_value = std::pair<const key_type&, const mapped_type&>;
 
  200   using iterator_value = std::pair<const key_type, mapped_type&>;
 
  202   class const_iterator;
 
  216     : 
public boost::iterator_facade<const_iterator,
 
  217                                     const const_iterator_value,
 
  218                                     std::bidirectional_iterator_tag,
 
  219                                     const const_iterator_value>
 
  226     const_iterator (
typename Impl_t::const_iterator 
it);
 
  246     friend class boost::iterator_core_access;
 
  265     bool equal (
const const_iterator& 
other) 
const;
 
  277     const const_iterator_value dereference() 
const;
 
  281     typename Impl_t::const_iterator m_impl;
 
  299     : 
public boost::iterator_facade<iterator,
 
  300                                     const iterator_value,
 
  301                                     std::bidirectional_iterator_tag,
 
  302                                     const iterator_value>
 
  309     iterator (
typename Impl_t::const_iterator 
it);
 
  322     friend class boost::iterator_core_access;
 
  323     friend class const_iterator;
 
  347     bool equal (
const const_iterator& 
other) 
const;
 
  353     const iterator_value dereference() 
const;
 
  357     typename Impl_t::const_iterator m_impl;
 
  369   const_iterator_range 
range() 
const;
 
  378   iterator_range 
range();
 
  384   const_iterator 
begin() 
const;
 
  390   const_iterator 
end() 
const;
 
  414   const_iterator cbegin() 
const;
 
  420   const_iterator cend() 
const;
 
  436   size_type 
count (
const key_type& 
key) 
const;
 
  445   const_iterator 
find (
const key_type& 
key) 
const;
 
  467   const mapped_type& at (
const key_type& 
key) 
const;
 
  481   mapped_type& at (
const key_type& 
key);
 
  491   std::pair<const_iterator, const_iterator>
 
  492   equal_range (
const key_type& 
key) 
const;
 
  505   std::pair<iterator, iterator>
 
  506   equal_range (
const key_type& 
key);
 
  520   std::pair<const_iterator, bool>
 
  521   emplace (
const key_type& 
key, 
const mapped_type& 
val,
 
  522            const Context_t& ctx = Updater_t::defaultContext());
 
  536   std::pair<const_iterator, bool>
 
  537   emplace (key_type&& 
key, 
const mapped_type& 
val,
 
  538            const Context_t& ctx = Updater_t::defaultContext());
 
  552   std::pair<const_iterator, bool>
 
  553   emplace (
const key_type& 
key, mapped_type&& 
val,
 
  554            const Context_t& ctx = Updater_t::defaultContext());
 
  568   std::pair<const_iterator, bool>
 
  569   emplace (key_type&& 
key, mapped_type&& 
val,
 
  570            const Context_t& ctx = Updater_t::defaultContext());
 
  584   std::pair<const_iterator, bool>
 
  585   emplace (
const key_type& 
key, std::unique_ptr<mapped_type> 
val,
 
  586            const Context_t& ctx = Updater_t::defaultContext());
 
  600   std::pair<const_iterator, bool>
 
  601   emplace (key_type&& 
key, std::unique_ptr<mapped_type> 
val,
 
  602            const Context_t& ctx = Updater_t::defaultContext());
 
  617   template <
class PAIR>
 
  618   std::pair<const_iterator, bool> insert (
const PAIR& 
p,
 
  619                                           const Context_t& ctx = Updater_t::defaultContext());
 
  634   template <
class PAIR>
 
  635   std::pair<const_iterator, bool> insert (PAIR&& 
p,
 
  636                                           const Context_t& ctx = Updater_t::defaultContext());
 
  648   template <
class InputIterator>
 
  649   void insert (InputIterator 
first, InputIterator last,
 
  650                const Context_t& ctx = Updater_t::defaultContext());
 
  661   void reserve (size_type capacity,
 
  662                 const Context_t& ctx = Updater_t::defaultContext());
 
  672   void rehash (size_type capacity);
 
  680   void quiescent (
const Context_t& ctx);
 
  693   void swap (ConcurrentStrToValMap& 
other);
 
  699   Updater_t& updater();
 
  707   static const std::string* keyAsString (val_t 
val);
 
  714   static val_t keyAsVal (
const std::string* 
s);
 
  722   static mapped_type* mappedAsMapped (val_t 
val);
 
  729   static val_t mappedAsVal (mapped_type* 
val);
 
  739   typename Impl_t::const_iterator 
get (
const key_type& 
key) 
const;
 
  752   std::pair<const_iterator, bool>
 
  753   put (std::unique_ptr<key_type> 
key,
 
  754        std::unique_ptr<mapped_type> 
val,
 
  755        const Context_t& ctx = Updater_t::defaultContext());
 
  771     std::hash<std::string> m_hash;
 
  796 #endif // not CXXUTILS_CONCURRENTSTRTOVALMAP_H