92 |
|
* @return the sum |
93 |
|
*/ |
94 |
|
public long sum() { |
95 |
– |
Cell[] as = cells; |
95 |
|
long sum = base; |
96 |
+ |
Cell[] as = cells; |
97 |
|
if (as != null) { |
98 |
|
int n = as.length; |
99 |
|
for (int i = 0; i < n; ++i) { |
127 |
|
* @return the sum |
128 |
|
*/ |
129 |
|
public long sumThenReset() { |
130 |
– |
Cell[] as = cells; |
130 |
|
long sum = base; |
131 |
+ |
Cell[] as = cells; |
132 |
|
base = 0L; |
133 |
|
if (as != null) { |
134 |
|
int n = as.length; |
135 |
|
for (int i = 0; i < n; ++i) { |
136 |
|
Cell a = as[i]; |
137 |
|
if (a != null) { |
138 |
< |
long v = a.value; |
138 |
> |
sum += a.value; |
139 |
|
a.value = 0L; |
140 |
– |
sum += v; |
140 |
|
} |
141 |
|
} |
142 |
|
} |