Class LsaMolecule
-
- All Implemented Interfaces:
-
it.unibo.alchemist.model.Dependency
,it.unibo.alchemist.model.Molecule
,it.unibo.alchemist.model.sapere.ILsaMolecule
,java.io.Serializable
,java.lang.Comparable
,java.lang.Iterable
public final class LsaMolecule extends SimpleMolecule implements ILsaMolecule
This class realizes an LsaMolecule, where arguments are of type Expression.
-
-
Field Summary
Fields Modifier and Type Field Description public final static HashString
SYN_D
public final static HashString
SYN_MOL_ID
public final static HashString
SYN_NEIGH
public final static HashString
SYN_NODE_ID
public final static HashString
SYN_O
public final static HashString
SYN_RAND
public final static HashString
SYN_ROUTE
public final static HashString
SYN_SELECTED
public final static HashString
SYN_T
public final static Dependency
EVERYTHING
public final static Dependency
EVERY_MOLECULE
public final static Dependency
MOVEMENT
-
Constructor Summary
Constructors Constructor Description LsaMolecule()
Empty molecule, no arguments. LsaMolecule(List<IExpression> listArgs)
Builds a new LsaMolecule by interpreting a list of IExpressions. LsaMolecule(LsaMolecule m)
Very fast constructor, produces a copy of an LsaMolecule. LsaMolecule(String argsString)
Builds a LsaMolecule by parsing the passed String. LsaMolecule(String argsString, String description)
Builds a LsaMolecule by parsing the passed String.
-
Method Summary
Modifier and Type Method Description List<IExpression>
allocateVar(Map<HashString, ITreeNode<out Object>> matches)
int
argsNumber()
int
compareTo(ILsaMolecule o)
boolean
dependsOn(Dependency m)
boolean
equals(Object o)
void
forEach(Consumer<in IExpression> action)
ILsaMolecule
generalize()
IExpression
getArg(int i)
boolean
hasDuplicateVariables()
int
hashCode()
boolean
isIdenticalTo(ILsaMolecule mol)
boolean
isIstance()
Iterator<IExpression>
iterator()
boolean
matches(ILsaMolecule mol)
boolean
matches(List<out IExpression> mol, boolean duplicateVariables)
boolean
moreGenericOf(ILsaMolecule mol)
int
size()
Spliterator<IExpression>
spliterator()
HashString
toHashString()
String
toString()
-
Methods inherited from class it.unibo.alchemist.model.molecules.SimpleMolecule
getName
-
Methods inherited from class it.unibo.alchemist.model.Dependency
makesDependent
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
LsaMolecule
LsaMolecule()
Empty molecule, no arguments.
-
LsaMolecule
LsaMolecule(List<IExpression> listArgs)
Builds a new LsaMolecule by interpreting a list of IExpressions.- Parameters:
listArgs
- the list of IExpressions
-
LsaMolecule
LsaMolecule(LsaMolecule m)
Very fast constructor, produces a copy of an LsaMolecule.- Parameters:
m
- the LsaMolecule to copy
-
LsaMolecule
LsaMolecule(String argsString)
Builds a LsaMolecule by parsing the passed String.- Parameters:
argsString
- the String to parse
-
-
Method Detail
-
allocateVar
List<IExpression> allocateVar(Map<HashString, ITreeNode<out Object>> matches)
- Parameters:
matches
- the map with the variable / value bindings- Returns:
the list of the arguments updated
-
argsNumber
int argsNumber()
- Returns:
the arguments number of the LSA structure.
-
compareTo
int compareTo(ILsaMolecule o)
-
dependsOn
boolean dependsOn(Dependency m)
-
forEach
void forEach(Consumer<in IExpression> action)
-
generalize
ILsaMolecule generalize()
- Returns:
a new ILsaMolecule produced by replacing all non-atomic and non-numeric values with variables.
-
getArg
IExpression getArg(int i)
- Parameters:
i
- : position of the argument to get- Returns:
the Expression represent the argument i.
-
hasDuplicateVariables
boolean hasDuplicateVariables()
- Returns:
true if this variable makes use of variables defined within the molecule itself
-
hashCode
int hashCode()
-
isIdenticalTo
boolean isIdenticalTo(ILsaMolecule mol)
- Parameters:
mol
- the molecule to compare to- Returns:
true if lsaMolecule is identical to mol, namely that all the arguments are equal
-
isIstance
boolean isIstance()
- Returns:
true if the molecule is an instance (not variable in the argouments).
-
iterator
@Nonnull() Iterator<IExpression> iterator()
-
matches
boolean matches(ILsaMolecule mol)
- Parameters:
mol
- the LsaMolecule to try to match with.- Returns:
true if the two molecules match
-
matches
boolean matches(List<out IExpression> mol, boolean duplicateVariables)
- Parameters:
mol
- the LsaMolecule to try to match withduplicateVariables
- if true, the matching of variables reused within the same tuple is enabled- Returns:
true if the two molecules match
-
moreGenericOf
boolean moreGenericOf(ILsaMolecule mol)
- Parameters:
mol
- the molecule to compare to- Returns:
true if the molecule is more generic than the one passed
-
size
int size()
- Returns:
the number of arguments
-
spliterator
Spliterator<IExpression> spliterator()
-
toHashString
HashString toHashString()
- Returns:
the string representing the molecule, in a faster implementation.
-
-
-
-