Class StickyBiFunc<X,​Y,​Z>

  • Type Parameters:
    X - Type of input
    Y - Type of input
    Z - Type of output
    All Implemented Interfaces:
    BiFunc<X,​Y,​Z>

    public final class StickyBiFunc<X,​Y,​Z>
    extends Object
    implements BiFunc<X,​Y,​Z>
    Func that accepts two arguments and caches previously calculated values and doesn't recalculate again.

    Pay attention that this class is not thread-safe. It is highly recommended to always decorate it with SyncBiFunc.

    This BiFunc decorator technically is an in-memory cache.

    There is no thread-safety guarantee.

    Since:
    0.13
    See Also:
    Sticky
    • Constructor Detail

      • StickyBiFunc

        public StickyBiFunc​(BiFunc<X,​Y,​Z> fnc)
        Ctor.
        Parameters:
        fnc - Func original
      • StickyBiFunc

        public StickyBiFunc​(BiFunc<X,​Y,​Z> fnc,
                            int max)
        Ctor.
        Parameters:
        fnc - Func original
        max - Maximum buffer size
        Since:
        0.26
    • Method Detail

      • apply

        public Z apply​(X first,
                       Y second)
                throws Exception
        Description copied from interface: BiFunc
        Apply it.
        Specified by:
        apply in interface BiFunc<X,​Y,​Z>
        Parameters:
        first - The first argument
        second - The second argument
        Returns:
        The result
        Throws:
        Exception - If fails