org.deri.iris.evaluation.topdown.oldt
Class MemoTable

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<IAtom,IRelation>
          extended by org.deri.iris.evaluation.topdown.oldt.MemoTable
All Implemented Interfaces:
Serializable, Cloneable, Map<IAtom,IRelation>

public class MemoTable
extends HashMap<IAtom,IRelation>
implements Map<IAtom,IRelation>

Author:
gigi
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
MemoTable()
          Constructor
 
Method Summary
 IRelation add(IAtom atom, ITuple tuple)
          Add a answer (which is an ITuple) to an atom.
 void addAll(IAtom atom, IRelation relationFromSubtree)
           
 boolean containsKey(IAtom atom)
           
 ITuple get(IAtom atom, int i)
          Get the ith answer tuple
 IRelation get(IAtom atom, Map<IVariable,ITerm> variableMap)
           
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Constructor Detail

MemoTable

public MemoTable()
Constructor

Method Detail

add

public IRelation add(IAtom atom,
                     ITuple tuple)
Add a answer (which is an ITuple) to an atom. If the relation was not initialized before (there was no answer related to the atom), the empty relation will be returned. Since the OLDT table does not allow null values, null is returned if the atom is null. If the tuple is null, the relation will be initialized with the empty relation or remain unchanged.

Parameters:
atom - the unique, ungrounded atom
tuple - a answer tuple. The arity of the tuple must be equal to the number of distinct variables in the atom.
Returns:
previous answer relation associated with specified atom.

get

public IRelation get(IAtom atom,
                     Map<IVariable,ITerm> variableMap)

get

public ITuple get(IAtom atom,
                  int i)
Get the ith answer tuple

Parameters:
atom - memo atom
i - index position
Returns:
answer tuple from answer relation, at the given index position or null if there was no answer found

containsKey

public boolean containsKey(IAtom atom)

addAll

public void addAll(IAtom atom,
                   IRelation relationFromSubtree)