Class ContainerIterators.ClosureIteratorEvaluator

java.lang.Object
net.ssehub.easy.varModel.cstEvaluation.ContainerIterators.CollectingIteratorEvaluator
net.ssehub.easy.varModel.cstEvaluation.ContainerIterators.ClosureIteratorEvaluator
All Implemented Interfaces:
IIteratorEvaluator
Enclosing class:
ContainerIterators

private static class ContainerIterators.ClosureIteratorEvaluator extends ContainerIterators.CollectingIteratorEvaluator
Implements a basic closure iterator which can stop on a cycle. Uses ContainerIterators.DATA_CLOSURE_MARKED and ContainerIterators.DATA_CLOSURE_CYCLIC.
Author:
Holger Eichelberger
  • Field Details

    • stopOnCycle

      private boolean stopOnCycle
  • Constructor Details

    • ClosureIteratorEvaluator

      private ClosureIteratorEvaluator(boolean stopOnCycle)
      Creates the closure iterator.
      Parameters:
      stopOnCycle - stop on a cycle or just ignore the already vited nodes and go on
  • Method Details

    • aggregate

      public Value aggregate(EvaluationAccessor result, Value iter, EvaluationAccessor value, Map<Object,Object> data) throws ValueDoesNotMatchTypeException
      Description copied from interface: IIteratorEvaluator
      Aggregate value to result.
      Parameters:
      result - the aggregating result
      iter - the current value of the iterator
      value - the value to be aggregated
      data - arbitrary data to be hold while actually evaluating the function
      Returns:
      a boolean value to indicate whether iteration/evaluation shall stop (true if iteration shall stop due to this evaluation, false else), a collection of values as instance of ListWrapperValue where to go on
      Throws:
      ValueDoesNotMatchTypeException - in case of type compatibility problems
    • hasCycle

      protected boolean hasCycle(Map<Object,Object> data)
      Returns whether a cycle was detected.
      Parameters:
      data - the data object
      Returns:
      true for cycle, false else
    • handleNextValue

      private boolean handleNextValue(Value value, ContainerValue result, Map<Object,Object> data, List<Value> nextValues) throws ValueDoesNotMatchTypeException
      Handles the next value by checking whether it was already added.
      Parameters:
      value - the value
      result - the result container to be changed if not already added
      data - the temporary data storing already added elements
      nextValues - the next values to be considered for iteration
      Returns:
      true if value was added to result, false else
      Throws:
      ValueDoesNotMatchTypeException - if adding value to result is failing
    • handleResult

      private void handleResult(boolean changed, EvaluationAccessor result, EvaluationAccessor value, int index)
      Handles the bound container elements of result.
      Parameters:
      changed - whether the result container was changed by the last evaluation
      result - the result accessor to be modified
      value - the value accessor
      index - the index of the bound element, no index if negative