本文整理汇总了C++中Pattern::getPattern方法的典型用法代码示例。如果您正苦于以下问题:C++ Pattern::getPattern方法的具体用法?C++ Pattern::getPattern怎么用?C++ Pattern::getPattern使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pattern
的用法示例。
在下文中一共展示了Pattern::getPattern方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// worker methods
bool Pattern::operator==(const Pattern & obj) const {
bool match = true;
if (&obj == 0) {
std::cout << "Pattern::operator ==: obj is null" << std::endl;
return false;
}
match = match && (this->getPattern() == obj.getPattern());
if (match == false) {
std::cout << "Pattern::equals: vector mismatch" << std::endl;
return false;
}
return true;
}
示例2: compare
double Pattern::compare(const Pattern & obj) const {
const std::vector<bool> this_pat = this->getPattern();
const std::vector<bool> obj_pat = obj.getPattern();
int this_sz = this_pat.size();
int obj_sz = obj_pat.size();
#ifdef PATTERN_DEBUG // DEBUG
std::cout << "Pattern::compare: this: ";
common::Misc::print(std::cout, this_pat);
std::cout << std::endl;
std::cout << "Pattern::compare: obj: ";
common::Misc::print(std::cout, obj_pat);
std::cout << std::endl;
#endif // DEBUG
if (this_sz == 0) {
std::cout << "Pattern::compare: this zero pattern mismatch" << std::endl;
return 0;
} else {
if (obj_sz == 0) {
std::cout << "Pattern::compare: obj zero pattern mismatch" << std::endl;
return 0;
}
}
if (this_sz != obj_sz) {
std::cout << "Pattern::compare: size mismatch " << std::endl;
return 0;
}
double fraction = static_cast<double>(1) / static_cast<double>(this_sz);
double match = 0;
std::vector<bool>::const_iterator it_this_vec = this_pat.begin();
const std::vector<bool>::const_iterator it_this_vec_end = this_pat.end();
std::vector<bool>::const_iterator it_obj_vec = obj_pat.begin();
const std::vector<bool>::const_iterator it_obj_vec_end = obj_pat.end();
while (it_this_vec != it_this_vec_end && it_obj_vec != it_obj_vec_end) {
if (*it_this_vec == *it_obj_vec) {
match += fraction;
}
++it_this_vec;
++it_obj_vec;
}
#ifdef PATTERN_DEBUG // DEBUG
std::cout << "Pattern::compare: match: " << match << std::endl;
#endif // DEBUG
return match;
}
示例3: pastePattern
void pastePattern(int x, int y, bool isReverse, Pattern const & pattern)
{
if ((0 <= x) && ((x + pattern.getWidth()) < CELL_LENGTH_1) && (0 <= y) && ((y + pattern.getHeight()) < CELL_LENGTH_0))
{
int i = 0;
for (auto const & row : *pattern.getPattern())
{
int j = 0;
for (auto const e : row)
{
if (isReverse)
{
(*cell)[y + j][x + i] = !e;
}
else
{
(*cell)[y + j][x + i] = e;
}
++j;
}
++i;
}
}
}