16 #include "boost/iterator/iterator_facade.hpp"
17 #include <type_traits>
21 #ifndef CXXUTILS_CONCURRENTPTRSET_H
22 #define CXXUTILS_CONCURRENTPTRSET_H
74 template <
class VALUE,
template <
class>
class UPDATER>
76 class ConcurrentPtrSet
89 using key_type =
VALUE*;
90 using const_key_type =
const VALUE*;
91 using size_type = size_t;
93 using Updater_t =
typename Impl_t::Updater_t;
95 using Context_t =
typename Updater_t::Context_t;
97 using Lock_t =
typename Impl_t::Lock_t;
108 ConcurrentPtrSet (Updater_t&& updater,
109 size_type capacity = 64,
110 const Context_t& ctx = Updater_t::defaultContext());
123 ConcurrentPtrSet (
const ConcurrentPtrSet&
other,
125 size_t capacity = 64,
126 const Context_t& ctx = Updater_t::defaultContext());
139 template <
class InputIterator>
140 ConcurrentPtrSet (InputIterator
f,
143 size_type capacity = 64,
144 const Context_t& ctx = Updater_t::defaultContext());
148 ConcurrentPtrSet (
const ConcurrentPtrSet&
other) =
delete;
149 ConcurrentPtrSet (ConcurrentPtrSet&&
other) =
delete;
150 ConcurrentPtrSet&
operator= (
const ConcurrentPtrSet&
other) =
delete;
163 size_type
size()
const;
175 size_t capacity()
const;
181 using const_iterator_value =
const key_type;
194 :
public boost::iterator_facade<const_iterator,
195 const const_iterator_value,
196 std::bidirectional_iterator_tag,
197 const const_iterator_value>
204 const_iterator (
typename Impl_t::const_iterator
it);
217 friend class boost::iterator_core_access;
235 bool equal (
const const_iterator&
other)
const;
241 key_type dereference()
const;
245 typename Impl_t::const_iterator m_impl;
256 const_iterator_range
range()
const;
262 const_iterator
begin()
const;
268 const_iterator
end()
const;
274 const_iterator cbegin()
const;
280 const_iterator cend()
const;
296 size_type
count (
const const_key_type
key)
const;
305 const_iterator
find (
const const_key_type
key)
const;
315 std::pair<const_iterator, const_iterator>
316 equal_range (
const const_key_type
key)
const;
340 std::pair<const_iterator, bool>
341 emplace (
const key_type
key,
342 const Context_t& ctx = Updater_t::defaultContext());
356 std::pair<const_iterator, bool>
357 emplace (
const Lock_t&
lock,
359 const Context_t& ctx = Updater_t::defaultContext());
373 std::pair<const_iterator, bool> insert (
const key_type
p);
381 template <
class InputIterator>
382 void insert (InputIterator
first, InputIterator last);
393 void reserve (size_type capacity,
394 const Context_t& ctx = Updater_t::defaultContext());
404 void rehash (size_type capacity);
412 void clear (
size_t capacity,
413 const Context_t& ctx = Updater_t::defaultContext());
420 void clear (
const Context_t& ctx = Updater_t::defaultContext());
428 void quiescent (
const Context_t& ctx);
447 Updater_t& updater();
455 static key_type keyAsPtr (val_t
val);
462 static val_t keyAsVal (
const const_key_type
p);
472 typename Impl_t::const_iterator
get (
const const_key_type
key)
const;
484 std::pair<const_iterator, bool>
485 put (
const key_type
key,
486 const Context_t& ctx = Updater_t::defaultContext());
499 std::pair<const_iterator, bool>
500 put (
const Lock_t&
lock,
502 const Context_t& ctx = Updater_t::defaultContext());
518 std::hash<const_key_type> m_hash;
543 #endif // not CXXUTILS_CONCURRENTPTRSET_H