Class AbstractPersistedTree<S,​T>

    • Constructor Detail

      • AbstractPersistedTree

        protected AbstractPersistedTree​(Metadata metadata,
                                        ProtelisAST<?>... branches)
        Parameters:
        metadata - A Metadata object containing information about the code that generated this AST node.
        branches - branches of this AbstractPersistedTree
      • AbstractPersistedTree

        protected AbstractPersistedTree​(Metadata metadata,
                                        java.util.List<ProtelisAST<?>> branches)
        Parameters:
        metadata - A Metadata object containing information about the code that generated this AST node.
        branches - branches of this AbstractPersistedTree
    • Method Detail

      • loadState

        protected final S loadState​(ExecutionContext context,
                                    java.util.function.Supplier<S> ifAbsent)
        Retrieves the function state from last round, or produces a new state otherwise.
        Parameters:
        context - the ExecutionContext
        ifAbsent - a 0-ary function producing the value if none is stored
        Returns:
        the previous state, if present, or the state computed by ifAbsent otherwise
      • saveState

        protected final void saveState​(ExecutionContext context,
                                       S obj)
        Stores the function state for the next round.
        Parameters:
        context - the ExecutionContext
        obj - the state