|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jauvm.util.Ambivalence<T>
public final class Ambivalence<T>
A class to facilitate non-deterministic programing with back-tracking.
This class helps in implementing non-deterministic programing algorithms doing a deep-first search on problem space solutions.
Nested Class Summary | |
---|---|
class |
Ambivalence.NoSolutionException
Thrown to indicate that there are no solutions in this Ambivalence object's problem space. |
Constructor Summary | |
---|---|
Ambivalence()
|
Method Summary | |
---|---|
T |
choose()
Indicates there is no choice of values to return at this point. |
T |
choose(T... values)
Ambiguously chooses one of its arguments to return. |
T |
choose(T value)
Indicates there is only one possible value to return at this point. |
void |
cover(Runnable runnable)
Covers all solutions defined by a Runnable object's run() method. |
void |
fail()
Causes the computation to fail at this point. |
void |
require(boolean condition)
Requires a certain condition to be true failing otherwise. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Ambivalence()
Method Detail |
---|
public T choose()
fail()
with a return type. It never returns, though.
Ambivalence.NoSolutionException
- if there are no alternative choices in the problem space to back-track to.fail()
public T choose(T value)
value
. The identity function.
value
- the value to return
value
public T choose(T... values)
choose(T value)
; invoked with no arguments, its the
same as choose()
, or a fail()
with a return type.
values
- the values from which to choose from
Ambivalence.NoSolutionException
- if no choice provides a solution and there are no alternative choices in the
problem space to back-track to.public void fail()
Ambivalence
object to back-track to previous choice points and try different
values for those.
Ambivalence.NoSolutionException
- if there are no alternative choices in the problem space to back-track to.public void require(boolean condition)
Ambivalence.NoSolutionException
- if there are no more sollutions in the problem space to trypublic void cover(Runnable runnable)
Runnable
object's run()
method.
This method takes a Runnable
object whose run()
method defines a problem space with this Ambivalence
object. This method will run that run()
method till it's normal termination for every
solution defined in the problem space.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |