private ETuple update(ETuple rec, int idx, EInteger incr) {
EInteger old = rec.elm(idx).testInteger();
if (old == null) return null;
EObject val = old.add(incr);
rec = ErlBif.setelement(idx, rec, val);
return rec;
}
private ETuple update(ETuple rec, int idx, EInteger incr, EInteger threshold, EInteger setvalue) {
EInteger old = rec.elm(idx).testInteger();
if (old == null) return null;
ENumber val = old.add(incr);
if (incr.is_ge(ESmall.ZERO)) {
if (threshold.is_lt(val)) {
val = setvalue;
}
} else {
if (val.is_lt(threshold)) {
val = setvalue;
}
}