JSHOP2
Class DelAddElement
java.lang.Object
JSHOP2.CompileTimeObject
JSHOP2.DelAddElement
- Direct Known Subclasses:
- DelAddAtomic, DelAddForAll, DelAddProtection
public abstract class DelAddElement
- extends CompileTimeObject
Each element in the delete/add list of an operator both at compile time and
run time is represented as an instance of a class derived from this
abstract class.
- Version:
- 1.0.3
- Author:
- Okhtay Ilghami, http://www.cs.umd.edu/~okhtay
Method Summary |
abstract void |
add(State s,
Term[] binding,
java.util.Vector[] delAddList)
What to do when an operator has this element in its add list and it is
being applied. |
abstract boolean |
del(State s,
Term[] binding,
java.util.Vector[] delAddList)
What to do when an operator has this element in its delete list and it is
being applied. |
abstract void |
setVarCount(int varCount)
To set the number of variables in this delete/add element. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DelAddElement
public DelAddElement()
add
public abstract void add(State s,
Term[] binding,
java.util.Vector[] delAddList)
- What to do when an operator has this element in its add list and it is
being applied.
- Parameters:
s
- the current state of the world.binding
- the binding to be applied before adding the element.delAddList
- an array of size 4 of atoms and protections deleted and added.
This is useful when a backtrack happens: Added atoms and
protections are retracted, and deleted atoms and protections are
added back to change the state of the world to what it was before
backtracked decision was made. The 4 elements of the array are
the deleted atoms, the added atoms, the deleted protections, and
the added protections repectively.
del
public abstract boolean del(State s,
Term[] binding,
java.util.Vector[] delAddList)
- What to do when an operator has this element in its delete list and it is
being applied.
- Parameters:
s
- the current state of the world.binding
- the binding to be applied before deleting the element.delAddList
- an array of size 4 of atoms and protections deleted and added.
This is useful when a backtrack happens: Added atoms and
protections are retracted, and deleted atoms and protections are
added back to change the state of the world to what it was before
backtracked decision was made. The 4 elements of array are the
the deleted atoms, added atoms, deleted protections and added
protections in that order.
- Returns:
true
if the atom(s) associated with this
delete/add element were deleted, false
otherwise,
i.e., when at least one of the atoms to be deleted was protected.
If this function returns false
, it means the
operator has failed and should be backtracked.
setVarCount
public abstract void setVarCount(int varCount)
- To set the number of variables in this delete/add element. It is used
when returning a binding since a binding is assumed to be an array of
this size. This function must be called at compile time, since at run
time the code to calculate the bindings has already been produced.
- Parameters:
varCount
- the number of variables.