Generating permutations and small buffer checks
This commit is contained in:
parent
d3df3dde09
commit
4a5877784b
3 changed files with 33 additions and 2 deletions
|
|
@ -318,4 +318,36 @@ namespace tp {
|
|||
mSize = newSize;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename tType>
|
||||
void generatePermutations(const Buffer<Buffer<tType>>& in, Buffer<Buffer<tType>>& out) {
|
||||
typedef long long Idx;
|
||||
|
||||
// sanity check
|
||||
for (const auto & vec : in) {
|
||||
if (!vec.size()) return;
|
||||
}
|
||||
|
||||
out.resize(in.size());
|
||||
auto len = Idx(1);
|
||||
for (const auto & vec : in) len *= (Idx) vec.size();
|
||||
for (auto i = 0; i < in.size(); i++) out[i].resize(len);
|
||||
|
||||
auto dub = Idx(1);
|
||||
for (auto power = (Idx) in.size() - 1; power >= 0; power--) {
|
||||
auto& vec = in[power];
|
||||
long long i = 0;
|
||||
while (i < len) {
|
||||
for (auto val : vec) {
|
||||
for (auto j = 0; j < dub; j++) {
|
||||
out[power][i] = val;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
dub *= (Idx) vec.size();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -18,8 +18,6 @@ namespace tp {
|
|||
#define DEBUG_ASSERT(exp) {}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(ENV_OS_WINDOWS)
|
||||
#define DEBUG_BREAK(expr) if (expr) { __debugbreak(); }
|
||||
#elif defined(ENV_OS_ANDROID)
|
||||
|
|
|
|||
1
TODO
1
TODO
|
|
@ -30,6 +30,7 @@ Utils:
|
|||
|
||||
Containers:
|
||||
Add variant size buffer
|
||||
Buffer add resize function
|
||||
Buffer improvements
|
||||
Add mem leakage tests
|
||||
Add check copy times
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue