请考虑以下三个Rcpp函数:
false
然后,将这些函数应用于S4类的实例,我得到:
true
我的问题是:
函数function WebForm_IsInVisibleContainer(ctrl: HTMLElement): boolean {
let current = ctrl;
while (true) {
if (
(isDisableableElement(current) && current.disabled) ||
current.style.display === 'none' ||
current.style.visibility === 'hidden'
) {
return false;
}
if (current.parentNode !== null &&
current.parentNode !== current &&
(current.parentNode as HTMLElement).tagName.toLowerCase() !== 'body'
) {
current = current.parentNode as HTMLElement;
} else {
return true;
}
}
}
的行为是否正确?考虑到void f(Rcpp::S4 A) {
Rcpp::NumericVector x = A.slot("x");
x[0] = 42;
}
void g(Rcpp::S4 A) {
Rcpp::NumericVector x = A.slot("x");
x.push_back(42);
}
void h(Rcpp::S4 A) {
Rcpp::NumericVector x = A.slot("x");
x.push_back(42);
A.slot("x") = x;
}
的工作方式,我希望> setClass(Class = "VectorClass", slots = list(x = "numeric"))
> A <- new("VectorClass", x = c(0))
> f(A)
> A
An object of class "VectorClass"
Slot "x":
[1] 42
> A <- new("VectorClass", x = c(0))
> g(A)
> A
An object of class "VectorClass"
Slot "x":
[1] 0
> A <- new("VectorClass", x = c(0))
> h(A)
> A
An object of class "VectorClass"
Slot "x":
[1] 0 42
修改g
的插槽f
。
我假设g
正在制作x
的副本,可能是在对A
的调用中调整矢量大小时。此副本可避免吗?有没有比h
更好的工作方式了?
谢谢!