原理是一样的,不管是加还是乘还是表达式,都是最后累加,源码: public long getThenReset() {
Cell[] as = cells; Cell a;
long result = base;
base = identity;
if (as != null) {
for (int i = 0; i < as.length; ++i) {
if ((a = as[i]) != null) {
long v = a.value;
a.value = identity;
result = function.applyAsLong(result, v);
}
}
}
return result;
}
可以看看源码分析:https://www.cnblogs.com/huangjuncong/p/9152510.html
https://www.jianshu.com/p/73ec78b4e336