Class FoldRight.FoldRightHelper<T>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private BinaryFunction<? super T,​? super T,​? extends T> function
      The wrapped function.
      private boolean hasSeed
      Flag to check the helper started or not.
      private T seed
      The seed object.
      private java.util.Stack<T> stk
      The stack where storing the wrapped function evaluations.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) T getResult()
      Get result after processing.
      void run​(T obj)
      Execute this procedure.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • stk

        private final java.util.Stack<T> stk
        The stack where storing the wrapped function evaluations.
      • function

        private final BinaryFunction<? super T,​? super T,​? extends T> function
        The wrapped function.
      • seed

        private final T seed
        The seed object.
      • hasSeed

        private final boolean hasSeed
        Flag to check the helper started or not.
    • Constructor Detail

      • FoldRightHelper

        public FoldRightHelper​(BinaryFunction<? super T,​? super T,​? extends T> function)
        Create a seedless FoldRightHelper.
        Parameters:
        function - The wrapped function
      • FoldRightHelper

        FoldRightHelper​(T seed,
                        BinaryFunction<? super T,​? super T,​? extends T> function)
        Create a new FoldRightHelper.
        Parameters:
        seed - initial right-side argument
        function - The wrapped function
    • Method Detail

      • run

        public void run​(T obj)
        Execute this procedure.
        Specified by:
        run in interface UnaryProcedure<T>
        Parameters:
        obj - an A parameter to this execution
      • getResult

        T getResult()
        Get result after processing. Get current result.
        Returns:
        Object