Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-feliks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Feliks Kiszkurno
ogs-feliks
Commits
58e4a87c
Commit
58e4a87c
authored
11 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
Remove element type from serialExecute. Add iterator version.
parent
4e63b20c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
AssemblerLib/SerialExecutor.h
+28
-9
28 additions, 9 deletions
AssemblerLib/SerialExecutor.h
with
28 additions
and
9 deletions
AssemblerLib/SerialExecutor.h
+
28
−
9
View file @
58e4a87c
...
...
@@ -18,22 +18,41 @@
namespace
AssemblerLib
{
/// Executes a \c f for each element
in input vecto
r.
/// Executes a \c f for each element
from the input containe
r.
/// Return values of the function call are ignored.
///
/// \tparam
T type of input vector elements
/// \tparam F \c f type
/// \tparam
C input container type.
/// \tparam F
\c f type
.
///
/// \param v a vector of T pointers
/// \param f a function that accepts a pointer to T and an index as arguments
template
<
typename
T
,
typename
F
>
/// \param c a container supporting access over operator[].
/// \param f a function that accepts a pointer to container's elements and
/// an index as arguments.
template
<
typename
C
,
typename
F
>
void
serialExecute
(
std
::
vector
<
T
*>
const
&
v
,
F
const
&
f
)
serialExecute
(
C
const
&
c
,
F
const
&
f
)
{
for
(
std
::
size_t
i
=
0
;
i
<
v
.
size
();
i
++
)
f
(
v
[
i
],
i
);
for
(
std
::
size_t
i
=
0
;
i
<
c
.
size
();
i
++
)
f
(
c
[
i
],
i
);
};
/// Executes a \c f for each element from the input range [first, last)
/// Return values of the function call are ignored.
///
/// \tparam I input iterator type.
/// \tparam F \c f type.
///
/// \param first iterator to the first element.
/// \param last iterator to one after the last element.
/// \param f a function accepting a pointer to container's elements and
/// an index as arguments.
template
<
typename
I
,
typename
F
>
void
serialExecute
(
I
first
,
I
last
,
F
const
&
f
)
{
std
::
size_t
count
=
0
;
while
(
first
!=
last
)
f
(
*
first
++
,
count
++
);
};
}
// namespace AssemblerLib
#endif // ASSEMBLERLIB_SERIALEXECUTOR_H_H
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment