Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenMesh
OpenMesh
Commits
a85ac689
Commit
a85ac689
authored
Nov 25, 2019
by
Jan Möbius
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'smart_range_improvement' into 'master'
Smart range improvement See merge request
!236
parents
e3d2c02a
65cafaf1
Pipeline
#12992
passed with stages
in 318 minutes and 53 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
src/OpenMesh/Core/Mesh/SmartRange.hh
src/OpenMesh/Core/Mesh/SmartRange.hh
+36
-0
No files found.
src/OpenMesh/Core/Mesh/SmartRange.hh
View file @
a85ac689
...
...
@@ -45,6 +45,7 @@
#include <utility>
#include <array>
#include <vector>
#include <set>
//== NAMESPACES ===============================================================
...
...
@@ -189,6 +190,41 @@ struct SmartRangeT
return
res
;
}
/** @brief Convert range to set.
*
* Converts the range of elements into a set of objects returned by functor \p f.
*
* @param f Functor that is applied to all elements before putting them into the set. If no functor is provided
* the set will contain the handles.
*/
template
<
typename
Functor
=
Identity
>
auto
to_set
(
Functor
&&
f
=
{})
->
std
::
set
<
typename
std
::
remove_reference
<
decltype
(
f
(
std
::
declval
<
HandleT
>
()))
>::
type
>
{
auto
range
=
static_cast
<
const
RangeT
*>
(
this
);
std
::
set
<
typename
std
::
remove_reference
<
decltype
(
f
(
std
::
declval
<
HandleT
>
()))
>::
type
>
res
;
for
(
const
auto
&
e
:
*
range
)
res
.
insert
(
f
(
e
));
return
res
;
}
/** @brief Get the first element that fulfills a condition.
*
* Finds the first element of the range for which the functor \p f evaluates to true.
* Returns an invalid handle if none evaluates to true
*
* @param f Functor that is applied to all elements before putting them into the set. If no functor is provided
* the set will contain the handles.
*/
template
<
typename
Functor
>
auto
first
(
Functor
&&
f
=
{})
->
HandleT
{
auto
range
=
static_cast
<
const
RangeT
*>
(
this
);
for
(
const
auto
&
e
:
*
range
)
if
(
f
(
e
))
return
e
;
return
HandleT
();
}
/** @brief Compute minimum.
*
* Computes the minimum of all objects returned by functor \p f.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment