forked from quantlibnode/quantlibnode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.hpp
More file actions
27 lines (23 loc) · 730 Bytes
/
Copy pathloop.hpp
File metadata and controls
27 lines (23 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef ohn_loop_hpp
#define ohn_loop_hpp
namespace ObjectHandler {
//! Invoke the contained function once for each item in the input vector.
template<class LoopFunction, class InputType, class OutputType>
void loop(
LoopFunction &loopFunction,
std::vector<InputType> &xIn,
std::vector<OutputType> &xOut) {
for (unsigned int i = 0; i < xIn.size(); i++) {
xOut.push_back(loopFunction(xIn[i]));
}
}
template<class LoopFunction, class InputType>
void loop(
LoopFunction &loopFunction,
std::vector<InputType> &xIn) {
for (unsigned int i = 0; i < xIn.size(); i++) {
loopFunction(xIn[i]);
}
}
}
#endif