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 Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateClosureIteratorEvaluator(boolean stopOnCycle) Creates the closure iterator. -
Method Summary
Modifier and TypeMethodDescriptionaggregate(EvaluationAccessor result, Value iter, EvaluationAccessor value, Map<Object, Object> data) Aggregatevaluetoresult.private booleanhandleNextValue(Value value, ContainerValue result, Map<Object, Object> data, List<Value> nextValues) Handles the next value by checking whether it was already added.private voidhandleResult(boolean changed, EvaluationAccessor result, EvaluationAccessor value, int index) Handles the bound container elements ofresult.protected booleanReturns whether a cycle was detected.Methods inherited from class net.ssehub.easy.varModel.cstEvaluation.ContainerIterators.CollectingIteratorEvaluator
getStartResult, postProcessResult
-
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 ValueDoesNotMatchTypeExceptionDescription copied from interface:IIteratorEvaluatorAggregatevaluetoresult.- Parameters:
result- the aggregating resultiter- the current value of the iteratorvalue- the value to be aggregateddata- arbitrary data to be hold while actually evaluating the function- Returns:
- a boolean value to indicate whether iteration/evaluation shall stop (
trueif iteration shall stop due to this evaluation,falseelse), a collection of values as instance ofListWrapperValuewhere to go on - Throws:
ValueDoesNotMatchTypeException- in case of type compatibility problems
-
hasCycle
Returns whether a cycle was detected.- Parameters:
data- the data object- Returns:
truefor cycle,falseelse
-
handleNextValue
private boolean handleNextValue(Value value, ContainerValue result, Map<Object, Object> data, List<Value> nextValues) throws ValueDoesNotMatchTypeExceptionHandles the next value by checking whether it was already added.- Parameters:
value- the valueresult- the result container to be changed if not already addeddata- the temporary data storing already added elementsnextValues- the next values to be considered for iteration- Returns:
trueifvaluewas added toresult,falseelse- Throws:
ValueDoesNotMatchTypeException- if addingvaluetoresultis failing
-
handleResult
private void handleResult(boolean changed, EvaluationAccessor result, EvaluationAccessor value, int index) Handles the bound container elements ofresult.- Parameters:
changed- whether the result container was changed by the last evaluationresult- the result accessor to be modifiedvalue- the value accessorindex- the index of the bound element, no index if negative
-