6 #include <initializer_list>
16 template<
typename _Key,
typename _Comp>
17 class vs_set_strategy;
26 template<
typename _Key,
typename _Comp = std::less<_Key>,
27 typename _Strategy = vs_set_strategy<_Key, _Comp>>
32 "Provided invalid strategy class in template");
38 typedef std::set<_Key, _Comp>::iterator
iterator;
53 vs_set(
const _Comp& __comp = _Comp())
54 : _v_s(std::set<_Key, _Comp>(__comp)) { }
64 vs_set(std::initializer_list<_Key> __l,
65 const _Comp& __comp = _Comp())
66 : _v_s(std::set<_Key, _Comp>(__l, __comp)) { }
74 : _v_s(__vs_set._v_s.Get()) { }
92 {
return _v_s.
Get().begin(); }
103 {
return _v_s.
Get().end(); }
111 {
return _v_s.
Get().size(); }
119 auto& _set = _v_s.
Get();
120 return _set.find(__x) != _set.end();
128 {
return _v_s.
Get().find(__x); }
146 return _v_s.
Set(_v_s.
Get(), [&](std::set<_Key, _Comp>& _set){return _set.insert(__x).second;});
162 template<
typename _Key,
typename _Comp>
168 merge(std::set<_Key, _Comp>& dst, std::set<_Key, _Comp>& src)
172 auto found = dst.find(i);
174 if (found != dst.end())
Wrapper to make any class Versioned.
const T & Get() const
Get the current value of the object in the current Revision.
bool Set(const T &v, const std::function< bool(T &)> &updater=nullptr)
Set new value of the object.
simpliest determenistic merge strategy.
void merge_same_element(std::set< _Key, _Comp > &dst, _Key &dstk, _Key &srck)
void merge(std::set< _Key, _Comp > &dst, std::set< _Key, _Comp > &src)
A versioned mimic of a stl::set, suitable for multithread.
size_type size() const noexcept
size of underlying set
iterator end() const noexcept
end constant iterator
bool insert(const _Key &__x)
Attempts to insert an element into the set.
vs_set(const _Comp &__comp=_Comp())
Creates a vs_set with no elements.
std::set< _Key, _Comp >::iterator iterator
vs_set(std::initializer_list< _Key > __l, const _Comp &__comp=_Comp())
Builds a vs_set from an initializer_list.
iterator begin() const noexcept
begin constant iterator
Versioned< std::set< _Key, _Comp >, _Strategy > _Versioned
std::set< _Key, _Comp >::size_type size_type
iterator find(const _Key &__x) const
find element in set
bool contains(const _Key &__x)
check if element is contained in set
vs_set(const vs_set &__vs_set)
vs_set copy constructor
concept IsMergeStrategy
Concept for compile-time type checking passed user strategies.
Implementation of the class Revision.
Implementation of the Versioned classes and interface.