@Test public void shouldMemoizeBiFunction() { final DoubleToIntFunction function = first -> 123; final DoubleFunction<String> keyfunction = a -> "key"; try (final Cache<String, Integer> cache = JCacheMemoize.createCache(ToDoubleBiFunction.class)) { final JCacheBasedDoubleToIntFunctionMemoizer<String> loader = new JCacheBasedDoubleToIntFunctionMemoizer<>( cache, keyfunction, function); Assert.assertEquals("Memoized value does not match expectation", 123, loader.applyAsInt(123)); } }
@Override public int applyAsInt(final double value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> Integer.valueOf(biFunction.applyAsInt(value))).intValue(); }
JCacheBasedDoubleToIntFunctionMemoizer extends AbstractJCacheBasedMemoizer<KEY, Integer> implements DoubleToIntFunction { @Override public int applyAsInt(final double value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> Integer.valueOf(biFunction.applyAsInt(value))).intValue(); } }
JCacheBasedDoubleToIntFunctionMemoizer extends AbstractJCacheBasedMemoizer<KEY, Integer> implements DoubleToIntFunction { @Override public int applyAsInt(final double value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> Integer.valueOf(biFunction.applyAsInt(value))).intValue(); } JCacheBasedDoubleToIntFunctionMemoizer(
            final Cache<KEY, Integer> cache,
            final DoubleFunction<KEY> keyFunction,
            final DoubleToIntFunction biFunction); }
JCacheBasedDoubleToIntFunctionMemoizer extends AbstractJCacheBasedMemoizer<KEY, Integer> implements DoubleToIntFunction { @Override public int applyAsInt(final double value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> Integer.valueOf(biFunction.applyAsInt(value))).intValue(); } JCacheBasedDoubleToIntFunctionMemoizer(
            final Cache<KEY, Integer> cache,
            final DoubleFunction<KEY> keyFunction,
            final DoubleToIntFunction biFunction); @Override int applyAsInt(final double value); }
JCacheBasedDoubleToIntFunctionMemoizer extends AbstractJCacheBasedMemoizer<KEY, Integer> implements DoubleToIntFunction { @Override public int applyAsInt(final double value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> Integer.valueOf(biFunction.applyAsInt(value))).intValue(); } JCacheBasedDoubleToIntFunctionMemoizer(
            final Cache<KEY, Integer> cache,
            final DoubleFunction<KEY> keyFunction,
            final DoubleToIntFunction biFunction); @Override int applyAsInt(final double value);  }