Class RepeatInfinitely
- All Implemented Interfaces:
Predicate, PredicateFactory
repeat - always succeeds.
repeat always succeeds even when an attempt is made to re-satisfy it.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanCould the next re-evaluation of this instance succeed?booleanevaluate()Attempts to satisfy the goal this instance represents.getPredicate(Term term) Returns aPredicateto be used in the evaluation of a goal.booleanShould instances of this implementation be re-evaluated when backtracking?Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PredicateFactory
isAlwaysCutOnBacktrack, preprocess
-
Constructor Details
-
RepeatInfinitely
public RepeatInfinitely()
-
-
Method Details
-
getPredicate
Description copied from interface:PredicateFactoryReturns aPredicateto be used in the evaluation of a goal.- Specified by:
getPredicatein interfacePredicateFactory- Parameters:
term- the term containing the arguments to use in the evaluation of the goal- Returns:
- Predicate to be used in the evaluation of the goal
- See Also:
-
isRetryable
public boolean isRetryable()Description copied from interface:PredicateFactoryShould instances of this implementation be re-evaluated when backtracking?Some goals (e.g.
X is 1) are only meant to be evaluated once (the statement is either true or false) while others (e.g.repeat(3)) are meant to be evaluated multiple times. For instances ofPredicatethat are designed to possibly havePredicate.evaluate()called on them multiple times for the same individual query this method should returntrue. For instances ofPredicatethat are designed to only be evaluated once per individual query this method should returnfalse.- Specified by:
isRetryablein interfacePredicateFactory- Returns:
trueif an attempt should be made to re-evaluate instances of implementing classes when backtracking,falseotherwise
-
evaluate
public boolean evaluate()Description copied from interface:PredicateAttempts to satisfy the goal this instance represents.Calling this method multiple times on a single instance allows all possible answers to be identified. An attempt to find a solution carries on from where the last successful call finished.
If
PredicateFactory.isRetryable()returnsfalsethen this method should only be called once per individual query (no attempt should be made to find alternative solutions).If
PredicateFactory.isRetryable()returnstruethen, in order to find all possible solutions for an individual query, this method should be recalled on backtracking until it returnsfalse. -
couldReevaluationSucceed
public boolean couldReevaluationSucceed()Description copied from interface:PredicateCould the next re-evaluation of this instance succeed?Specifies whether a specific instance of a specific implementation of
Predicate, that has already hadPredicate.evaluate()called on it at least once, could possibly returntruethe next timePredicate.evaluate()is called on it. i.e. is it worth trying to continue to find solutions for the specific query this particular instance represents and has been evaluating?(Note: the difference between this method and
PredicateFactory.isRetryable()is thatPredicateFactory.isRetryable()deals with whether, in general, a specific implementation (rather than instance) ofPredicatecould ever produce multiple answers for an individual query.)- Specified by:
couldReevaluationSucceedin interfacePredicate- Returns:
trueif an attempt to re-evaluate this instance could possible succeed,falseotherwise
-