15 #include "boost/iterator/iterator_facade.hpp"
16 #include "boost/range/iterator_range.hpp"
17 #include <type_traits>
20 #ifndef CXXUTILS_CONCURRENTPTRSET_H
21 #define CXXUTILS_CONCURRENTPTRSET_H
73 template <
class VALUE,
template <
class>
class UPDATER>
75 class ConcurrentPtrSet
88 using key_type =
VALUE*;
89 using const_key_type =
const VALUE*;
90 using size_type = size_t;
92 using Updater_t =
typename Impl_t::Updater_t;
94 using Context_t =
typename Updater_t::Context_t;
96 using Lock_t =
typename Impl_t::Lock_t;
107 ConcurrentPtrSet (Updater_t&& updater,
108 size_type capacity = 64,
109 const Context_t& ctx = Updater_t::defaultContext());
122 ConcurrentPtrSet (
const ConcurrentPtrSet&
other,
124 size_t capacity = 64,
125 const Context_t& ctx = Updater_t::defaultContext());
138 template <
class InputIterator>
139 ConcurrentPtrSet (InputIterator
f,
142 size_type capacity = 64,
143 const Context_t& ctx = Updater_t::defaultContext());
147 ConcurrentPtrSet (
const ConcurrentPtrSet&
other) =
delete;
148 ConcurrentPtrSet (ConcurrentPtrSet&&
other) =
delete;
149 ConcurrentPtrSet&
operator= (
const ConcurrentPtrSet&
other) =
delete;
162 size_type
size()
const;
174 size_t capacity()
const;
180 using const_iterator_value =
const key_type;
193 :
public boost::iterator_facade<const_iterator,
194 const const_iterator_value,
195 std::bidirectional_iterator_tag,
196 const const_iterator_value>
203 const_iterator (
typename Impl_t::const_iterator
it);
216 friend class boost::iterator_core_access;
234 bool equal (
const const_iterator&
other)
const;
240 key_type dereference()
const;
244 typename Impl_t::const_iterator m_impl;
249 typedef boost::iterator_range<const_iterator> const_iterator_range;
255 const_iterator_range
range()
const;
261 const_iterator
begin()
const;
267 const_iterator
end()
const;
273 const_iterator cbegin()
const;
279 const_iterator cend()
const;
295 size_type
count (
const const_key_type
key)
const;
304 const_iterator
find (
const const_key_type
key)
const;
314 std::pair<const_iterator, const_iterator>
315 equal_range (
const const_key_type
key)
const;
339 std::pair<const_iterator, bool>
340 emplace (
const key_type
key,
341 const Context_t& ctx = Updater_t::defaultContext());
355 std::pair<const_iterator, bool>
356 emplace (
const Lock_t& lock,
358 const Context_t& ctx = Updater_t::defaultContext());
372 std::pair<const_iterator, bool> insert (
const key_type
p);
380 template <
class InputIterator>
381 void insert (InputIterator
first, InputIterator last);
392 void reserve (size_type capacity,
393 const Context_t& ctx = Updater_t::defaultContext());
403 void rehash (size_type capacity);
411 void clear (
size_t capacity,
412 const Context_t& ctx = Updater_t::defaultContext());
419 void clear (
const Context_t& ctx = Updater_t::defaultContext());
427 void quiescent (
const Context_t& ctx);
446 Updater_t& updater();
454 static key_type keyAsPtr (val_t
val);
461 static val_t keyAsVal (
const const_key_type
p);
471 typename Impl_t::const_iterator
get (
const const_key_type
key)
const;
483 std::pair<const_iterator, bool>
484 put (
const key_type
key,
485 const Context_t& ctx = Updater_t::defaultContext());
498 std::pair<const_iterator, bool>
499 put (
const Lock_t& lock,
501 const Context_t& ctx = Updater_t::defaultContext());
517 std::hash<const_key_type> m_hash;
542 #endif // not CXXUTILS_CONCURRENTPTRSET_H