![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
#include <iostream>#include <string>#include <algorithm>#include "tbb/parallel_for.h"#include "tbb/blocked_range.h"
Include dependency graph for sub_string_finder_pretty.cpp:Go to the source code of this file.
Classes | |
| class | SubStringFinder |
Functions | |
| int | main (int argc, char *argv[]) |
Variables | |
| static const size_t | N = 9 |
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 66 of file sub_string_finder_pretty.cpp.
References N, and tbb::parallel_for().
{
std::string str[N] = { std::string("a"), std::string("b") };
for (size_t i = 2; i < N; ++i) str[i] = str[i-1]+str[i-2];
std::string &to_scan = str[N-1];
std::cout << "String to scan: " << to_scan << std::endl;
size_t *max = new size_t[to_scan.size()];
size_t *pos = new size_t[to_scan.size()];
parallel_for(blocked_range<size_t>(0, to_scan.size(), 100),
SubStringFinder( to_scan, max, pos ) );
for (size_t i = 0; i < to_scan.size(); ++i) {
for (size_t j = 0; j < to_scan.size(); ++j) {
if (j >= i && j < i + max[i]) std::cout << "_";
else std::cout << " ";
}
std::cout << std::endl << to_scan << std::endl;
for (size_t j = 0; j < to_scan.size(); ++j) {
if (j >= pos[i] && j < pos[i] + max[i]) std::cout << "*";
else std::cout << " ";
}
std::cout << std::endl;
}
delete[] max;
delete[] pos;
return 0;
}
const size_t N = 9 [static] |
Definition at line 37 of file sub_string_finder_pretty.cpp.
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.