Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
amdis-core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
amdis
amdis-core
Merge requests
!142
cleanup for petscsolver
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
cleanup for petscsolver
issue/cleanup_for_petscsolver
into
master
Overview
0
Commits
17
Changes
7
Merged
Praetorius, Simon
requested to merge
issue/cleanup_for_petscsolver
into
master
5 years ago
Overview
0
Commits
17
Changes
7
Expand
0
0
Merge request reports
Compare
master
version 3
28f25da7
5 years ago
version 2
676b03c6
5 years ago
version 1
d39bb560
5 years ago
master (base)
and
version 2
latest version
71a24c5d
17 commits,
5 years ago
version 3
28f25da7
16 commits,
5 years ago
version 2
676b03c6
15 commits,
5 years ago
version 1
d39bb560
14 commits,
5 years ago
7 files
+
120
−
41
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
Search (e.g. *.vue) (Ctrl+P)
src/amdis/common/Algorithm.hpp
+
41
−
10
Options
#pragma once
#include
<algorithm>
#include
<functional>
#include
<utility>
namespace
AMDiS
{
template
<
class
InputIter
,
class
T
,
class
Func
>
void
split
(
InputIter
first
,
InputIter
end
,
T
const
&
t
,
Func
f
)
/// \brief Split a sequence `[first,last)` by the separators `sep` and pass the tokens as
/// begin-end iterator pair to the provided functor `f = void(InputIterator, InputIterator)`
template
<
class
InputIter
,
class
Tp
,
class
BinaryFunc
>
void
split
(
InputIter
first
,
InputIter
last
,
Tp
sep
,
BinaryFunc
f
)
{
if
(
first
==
end
)
if
(
first
==
last
)
return
;
while
(
true
)
{
InputIter
found
=
std
::
find
(
first
,
end
,
t
);
InputIter
found
=
std
::
find
(
first
,
last
,
sep
);
f
(
first
,
found
);
if
(
found
==
end
)
if
(
found
==
last
)
break
;
first
=
++
found
;
}
}
template
<
class
InputIter
,
class
SeparaterIter
,
class
Func
>
void
split
(
InputIter
first
,
InputIter
end
,
SeparaterIter
s_first
,
SeparaterIter
s_end
,
Func
f
)
/// \brief Split a sequence `[first,last)` by any of the separators `[s_first, s_last)` and pass the tokens as
/// begin-end iterator pair to the provided functor `f = void(InputIterator, InputIterator)`
template
<
class
InputIter
,
class
SeparaterIter
,
class
BinaryFunc
>
void
split
(
InputIter
first
,
InputIter
last
,
SeparaterIter
s_first
,
SeparaterIter
s_last
,
BinaryFunc
f
)
{
if
(
first
==
end
)
if
(
first
==
last
)
return
;
while
(
true
)
{
InputIter
found
=
std
::
find_first_of
(
first
,
end
,
s_first
,
s_
end
);
InputIter
found
=
std
::
find_first_of
(
first
,
last
,
s_first
,
s_
last
);
f
(
first
,
found
);
if
(
found
==
end
)
if
(
found
==
last
)
break
;
first
=
++
found
;
}
}
/// \brief Output the cumulative sum of one range to a second range
// NOTE: backport of std::exclusive_scan from c++17
template
<
class
InputIter
,
class
OutputIter
,
class
Tp
,
class
BinaryOperation
>
OutputIter
exclusive_scan
(
InputIter
first
,
InputIter
last
,
OutputIter
result
,
Tp
init
,
BinaryOperation
binary_op
)
{
while
(
first
!=
last
)
{
auto
v
=
init
;
init
=
binary_op
(
init
,
*
first
);
++
first
;
*
result
++
=
std
::
move
(
v
);
}
return
result
;
}
/// \brief Output the cumulative sum of one range to a second range
// NOTE: backport of std::exclusive_scan from c++17
template
<
class
InputIter
,
class
OutputIter
,
class
Tp
>
inline
OutputIter
exclusive_scan
(
InputIter
first
,
InputIter
last
,
OutputIter
result
,
Tp
init
)
{
return
AMDiS
::
exclusive_scan
(
first
,
last
,
result
,
std
::
move
(
init
),
std
::
plus
<>
());
}
}
\ No newline at end of file
Loading