dropped [c]visit_until

This commit is contained in:
joaquintides
2023-07-24 20:13:18 +02:00
parent 5a4d93a72d
commit 470abf41d8
5 changed files with 5 additions and 155 deletions

View File

@ -8,7 +8,7 @@
== Release 1.84.0 == Release 1.84.0
* Added `[c]visit_until` and `[c]visit_while` operations to `boost::concurrent_map`, * Added `[c]visit_while` operations to `boost::concurrent_map`,
with serial and parallel variants. with serial and parallel variants.
== Release 1.83.0 - Major update == Release 1.83.0 - Major update

View File

@ -162,23 +162,17 @@ Traversal can be interrupted midway:
int key = 0; int key = 0;
int value = ...; int value = ...;
bool found = m.visit_until([&](const auto& x) { bool found = !m.visit_while([&](const auto& x) {
if(x.second == value) { if(x.second == value) {
key = x.first; key = x.first;
return true; // finish return false; // finish
} }
else { else {
return false; // keep on visiting return true; // keep on visiting
} }
}); });
if(found) { ... } if(found) { ... }
// check if all values are != 0
bool all_ok = m.visit_while([&](const auto& x) {
return x.second != 0;
});
---- ----
There is one last whole-table visitation operation, `erase_if`: There is one last whole-table visitation operation, `erase_if`:
@ -190,7 +184,7 @@ m.erase_if([](auto& x) {
}); });
---- ----
`visit_until`, `visit_while` and `erase_if` can also be parallelized. Note that, in order to increase efficiency, `visit_while` and `erase_if` can also be parallelized. Note that, in order to increase efficiency,
whole-table visitation operations do not block the table during execution: this implies that elements whole-table visitation operations do not block the table during execution: this implies that elements
may be inserted, modified or erased by other threads during visitation. It is may be inserted, modified or erased by other threads during visitation. It is
advisable not to assume too much about the exact global state of a `boost::concurrent_flat_map` advisable not to assume too much about the exact global state of a `boost::concurrent_flat_map`

View File

@ -114,16 +114,6 @@ namespace boost {
template<class ExecutionPolicy, class F> template<class ExecutionPolicy, class F>
void xref:#concurrent_flat_map_parallel_cvisit_all[cvisit_all](ExecutionPolicy&& policy, F f) const; void xref:#concurrent_flat_map_parallel_cvisit_all[cvisit_all](ExecutionPolicy&& policy, F f) const;
template<class F> bool xref:#concurrent_flat_map_cvisit_until[visit_until](F f);
template<class F> bool xref:#concurrent_flat_map_cvisit_until[visit_until](F f) const;
template<class F> bool xref:#concurrent_flat_map_cvisit_until[cvisit_until](F f) const;
template<class ExecutionPolicy, class F>
bool xref:#concurrent_flat_map_parallel_cvisit_until[visit_until](ExecutionPolicy&& policy, F f);
template<class ExecutionPolicy, class F>
bool xref:#concurrent_flat_map_parallel_cvisit_until[visit_until](ExecutionPolicy&& policy, F f) const;
template<class ExecutionPolicy, class F>
bool xref:#concurrent_flat_map_parallel_cvisit_until[cvisit_until](ExecutionPolicy&& policy, F f) const;
template<class F> bool xref:#concurrent_flat_map_cvisit_while[visit_while](F f); template<class F> bool xref:#concurrent_flat_map_cvisit_while[visit_while](F f);
template<class F> bool xref:#concurrent_flat_map_cvisit_while[visit_while](F f) const; template<class F> bool xref:#concurrent_flat_map_cvisit_while[visit_while](F f) const;
template<class F> bool xref:#concurrent_flat_map_cvisit_while[cvisit_while](F f) const; template<class F> bool xref:#concurrent_flat_map_cvisit_while[cvisit_while](F f) const;
@ -740,50 +730,6 @@ Unsequenced execution policies are not allowed.
--- ---
==== [c]visit_until
```c++
template<class F> bool visit_until(F f);
template<class F> bool visit_until(F f) const;
template<class F> bool cvisit_until(F f) const;
```
Successively invokes `f` with references to each of the elements in the table until `f` returns `true`
or all the elements are visited.
Such references to the elements are const iff `*this` is const.
[horizontal]
Returns:;; `true` iff `f` ever returns `true`.
---
==== Parallel [c]visit_until
```c++
template<class ExecutionPolicy, class F> bool visit_until(ExecutionPolicy&& policy, F f);
template<class ExecutionPolicy, class F> bool visit_until(ExecutionPolicy&& policy, F f) const;
template<class ExecutionPolicy, class F> bool cvisit_until(ExecutionPolicy&& policy, F f) const;
```
Invokes `f` with references to each of the elements in the table until `f` returns `true`
or all the elements are visited.
Such references to the elements are const iff `*this` is const.
Execution is parallelized according to the semantics of the execution policy specified.
[horizontal]
Returns:;; `true` iff `f` ever returns `true`.
Throws:;; Depending on the exception handling mechanism of the execution policy used, may call `std::terminate` if an exception is thrown within `f`.
Notes:;; Only available in compilers supporting C++17 parallel algorithms. +
+
These overloads only participate in overload resolution if `std::is_execution_policy_v<std::remove_cvref_t<ExecutionPolicy>>` is `true`. +
+
Unsequenced execution policies are not allowed. +
+
Parallelization implies that execution does not necessary finish as soon as `f` returns `true`, and as a result
`f` may be invoked with further elements for which the return value is also `true`.
---
==== [c]visit_while ==== [c]visit_while
```c++ ```c++

View File

@ -355,56 +355,6 @@ namespace boost {
} }
#endif #endif
template <class F> bool visit_until(F f)
{
BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F)
return table_.visit_until(f);
}
template <class F> bool visit_until(F f) const
{
BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
return table_.visit_until(f);
}
template <class F> bool cvisit_until(F f) const
{
BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
return table_.cvisit_until(f);
}
#if defined(BOOST_UNORDERED_PARALLEL_ALGORITHMS)
template <class ExecPolicy, class F>
typename std::enable_if<detail::is_execution_policy<ExecPolicy>::value,
bool>::type
visit_until(ExecPolicy&& p, F f)
{
BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F)
BOOST_UNORDERED_STATIC_ASSERT_EXEC_POLICY(ExecPolicy)
return table_.visit_until(p, f);
}
template <class ExecPolicy, class F>
typename std::enable_if<detail::is_execution_policy<ExecPolicy>::value,
bool>::type
visit_until(ExecPolicy&& p, F f) const
{
BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
BOOST_UNORDERED_STATIC_ASSERT_EXEC_POLICY(ExecPolicy)
return table_.visit_until(p, f);
}
template <class ExecPolicy, class F>
typename std::enable_if<detail::is_execution_policy<ExecPolicy>::value,
bool>::type
cvisit_until(ExecPolicy&& p, F f) const
{
BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F)
BOOST_UNORDERED_STATIC_ASSERT_EXEC_POLICY(ExecPolicy)
return table_.cvisit_until(p, f);
}
#endif
template <class F> bool visit_while(F f) template <class F> bool visit_while(F f)
{ {
BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F) BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F)

View File

@ -539,46 +539,6 @@ public:
} }
#endif #endif
template<typename F> bool visit_until(F&& f)
{
return !visit_while([&](value_type& x){return !f(x);});
}
template<typename F> bool visit_until(F&& f)const
{
return !visit_while([&](const value_type& x){return !f(x);});
}
template<typename F> bool cvisit_until(F&& f)const
{
return visit_while(std::forward<F>(f));
}
#if defined(BOOST_UNORDERED_PARALLEL_ALGORITHMS)
template<typename ExecutionPolicy,typename F>
bool visit_until(ExecutionPolicy&& policy,F&& f)
{
return !visit_while(
std::forward<ExecutionPolicy>(policy),
[&](value_type& x){return !f(x);});
}
template<typename ExecutionPolicy,typename F>
bool visit_until(ExecutionPolicy&& policy,F&& f)const
{
return !visit_while(
std::forward<ExecutionPolicy>(policy),
[&](const value_type& x){return !f(x);});
}
template<typename ExecutionPolicy,typename F>
bool cvisit_until(ExecutionPolicy&& policy,F&& f)const
{
return visit_until(
std::forward<ExecutionPolicy>(policy),std::forward<F>(f));
}
#endif
template<typename F> bool visit_while(F&& f) template<typename F> bool visit_while(F&& f)
{ {
return visit_while_impl(group_exclusive{},std::forward<F>(f)); return visit_while_impl(group_exclusive{},std::forward<F>(f));