compute method

R compute(
  1. T value
)

Computes and caches value.

Implementation

R compute(T value) {
  var key = generateKey(value);

  var prev = _cache[key];
  if (prev != null) return prev;

  ++_computationCount;
  var result = function(value);

  _cache[key] = result;
  return result;
}