我正在浏览Qt资源,并注意到了这一点
QUuid &operator=(const GUID &guid)
{
*this = QUuid(guid);
return *this;
}
Run Code Online (Sandbox Code Playgroud)
我以前从没见过"这个"的作业.赋予"this"的作用是什么?
我知道如何在for循环中使用auto关键字来按值或引用迭代这个数组.
struct A {
void fun() {};
};
int main() {
A a[2];
// Value
for (auto x : a) {
x.fun();
}
// Ref
for (auto& x : a) {
x.fun();
}
// Pointer
//for (...) {
x->fun();
}
}
Run Code Online (Sandbox Code Playgroud)
所以我正在寻找这个约定的第三个版本.我如何在这里使用指针?
因此通常使用四个for循环来实现通常且非常低效的最小/最大过滤器.
for( index1 < dy ) { // y loop
for( index2 < dx ) { // x loop
for( index3 < StructuringElement.dy() ) { // kernel y
for( index4 < StructuringElement.dx() ) { // kernel x
pixel = src(index3+index4);
val = (pixel > val) ? pixel : val; // max
}
}
dst(index2, index1) = val;
}
}
Run Code Online (Sandbox Code Playgroud)
然而,这种方法效率很低,因为它再次检查先前检查的值.所以我想知道在下一次迭代中使用先前检查的值来实现这个的方法是什么?
可以对结构元素大小/原点进行任何假设.
更新:我特别渴望了解这种或某种实现的任何见解:http://dl.acm.org/citation.cfm?id = 2114689