-
-
Save bananu7/df047a7ba5ce470fa02a to your computer and use it in GitHub Desktop.
Uh.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename A, typename B> | |
class ArrayRunner { | |
std::vector<A> a; | |
std::vector<B> b; | |
std::vector<bool> arr; | |
public: | |
/* | |
A1 A2 AN | |
B1 x o ... | |
B2 o ... | |
BN x ... | |
*/ | |
ArrayRunner(std::vector<GLenum> _a, std::vector<GLenum> _b, std::vector<bool> _arr) | |
: a(boost::move(_a)) | |
, b(_b) | |
, arr(_arr) | |
{ | |
if (a.size() * b.size() != arr.size()) | |
throw std::runtime_error("The size of boolean array must be the size of the header vectors multiplied!"); | |
} | |
bool arr_n (int x, int y) { | |
return arr.at(x + y * a.size()); | |
} | |
void map(boost::function<void(A,B)> & fn) { | |
for (std::vector<B>::size_type bi = 0; bi < b.size(); ++bi) { | |
for (std::vector<A>::size_type ai = 0; ai < a.size(); ++ai) { | |
if (arr_n(ai, bi)) { | |
fn(a[ai], b[bi]); | |
} | |
} | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment