JSHOP2
Class Precondition

java.lang.Object
  extended by JSHOP2.Precondition
Direct Known Subclasses:
PreconditionAssign, PreconditionAtomic, PreconditionCall, PreconditionForAll, PreconditionNegation, PreconditionNil

public abstract class Precondition
extends java.lang.Object

This abstract class represents an iterator over all the possible bindings that can satisfy its corresponding logical expression at run time.

Version:
1.0.3
Author:
Okhtay Ilghami, http://www.cs.umd.edu/~okhtay

Field Summary
(package private)  Term[][] bindings
          The array that stores the sorted satisfiers for this logical precondition if this is a :sort-by logical precondition.
(package private)  int bindingsIdx
          The index pointing to the next satisfier to be returned in case this is a :sort-by logical precondition.
private  java.util.Comparator<Term[]> comp
          The function to be used to sort the possible bindings if this is a :sort-by logical precondition.
private  boolean first
          Whether or not this logical expression is marked :first.
private  boolean firstCall
          Whether or not this is the first time the nextBinding function is called for this object after the latest call to its reset function.
 
Constructor Summary
Precondition()
           
 
Method Summary
abstract  void bind(Term[] binding)
          This abstract function binds the logical expression to a given binding.
 Term[] nextBinding()
          This function returns the next satisfier for this logical expression.
protected abstract  Term[] nextBindingHelper()
          This abstract function is called by the nextBinding function and does the subclass-specific part of the finding the next binding.
 void reset()
          This function resets this iterator so that it can iterate over again.
protected abstract  void resetHelper()
          This abstract function is called by the reset function and does the subclass-specific part of the resetting.
 Precondition setComparator(java.util.Comparator<Term[]> compIn)
          To set the function to be used to sort the possible bindings that satisfy this logical precondition.
 void setFirst(boolean firstIn)
          To set whether or not this function is marked :fist.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bindings

Term[][] bindings
The array that stores the sorted satisfiers for this logical precondition if this is a :sort-by logical precondition.


bindingsIdx

int bindingsIdx
The index pointing to the next satisfier to be returned in case this is a :sort-by logical precondition.


comp

private java.util.Comparator<Term[]> comp
The function to be used to sort the possible bindings if this is a :sort-by logical precondition.


first

private boolean first
Whether or not this logical expression is marked :first.


firstCall

private boolean firstCall
Whether or not this is the first time the nextBinding function is called for this object after the latest call to its reset function.

Constructor Detail

Precondition

public Precondition()
Method Detail

bind

public abstract void bind(Term[] binding)
This abstract function binds the logical expression to a given binding.

Parameters:
binding - the given binding.

nextBinding

public Term[] nextBinding()
This function returns the next satisfier for this logical expression.

Returns:
the next satisfier as an array of terms, each element of which is either what its corresponding variable should be mapped to, or null when that variable is not mapped under this satisfier, null if there is no such satisfier.

nextBindingHelper

protected abstract Term[] nextBindingHelper()
This abstract function is called by the nextBinding function and does the subclass-specific part of the finding the next binding.


reset

public void reset()
This function resets this iterator so that it can iterate over again. Note that this will undo any bindings and/or iterations done before.


resetHelper

protected abstract void resetHelper()
This abstract function is called by the reset function and does the subclass-specific part of the resetting.


setComparator

public Precondition setComparator(java.util.Comparator<Term[]> compIn)
To set the function to be used to sort the possible bindings that satisfy this logical precondition.

Parameters:
compIn - the function to be used to sort the possible bindings in case this is a :sort-by logical precondition, null otherwise.
Returns:
this object.

setFirst

public void setFirst(boolean firstIn)
To set whether or not this function is marked :fist.

Parameters:
firstIn - true if this logical expression is marked :first, false otherwise.