Class BetaMemory
- java.lang.Object
-
- jadex.rules.rulesystem.rete.nodes.BetaMemory
-
- Direct Known Subclasses:
NotMemory
public class BetaMemory extends java.lang.Object
Memory for a beta node. It consists of: - indexed memories for each equal constraint (optional for speed) - a result memory (collection)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BetaMemory.IndexedConstraintMemory
A memory for an indexed constraint.
-
Constructor Summary
Constructors Constructor Description BetaMemory(IOAVState state)
Create a new beta memory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addObject(java.lang.Object value, java.lang.Object object, ConstraintIndexer ci)
Add an value -> object pair to the object index.boolean
addResultTuple(Tuple tuple)
Add a tuple to the result.void
addTuple(java.lang.Object value, Tuple tuple, ConstraintIndexer ci)
Add an value -> object pair to the tuple index.protected BetaMemory.IndexedConstraintMemory
getIndexedMemory(ConstraintIndexer ci)
Get the indexed memory per constraint indexer.java.util.Set
getObjects(Tuple tuple, ConstraintIndexer ci)
Get the indexed objects per tuple.java.util.Collection
getResultMemory()
Get the result memory.java.util.Set
getTuples(java.lang.Object object, ConstraintIndexer ci)
Get the indexed tuples per object.void
removeObject(java.lang.Object object, ConstraintIndexer ci)
Remove an object from the object index.boolean
removeResultTuple(Tuple tuple)
Remove from the result.void
removeTuple(Tuple tuple, ConstraintIndexer ci)
Remove an value -> object pair from the tuple index.int
size()
Get the size of the beta memory (including indexed memories).java.lang.String
toString()
Get the string representation.
-
-
-
Field Detail
-
state
protected IOAVState state
The state.
-
xmems
protected java.util.Map xmems
The indexed memories (indexed constraint evaluator -> memory).
-
resultmem
protected java.util.Set resultmem
The result memory.
-
-
Constructor Detail
-
BetaMemory
public BetaMemory(IOAVState state)
Create a new beta memory.- Parameters:
node
- The beta node.
-
-
Method Detail
-
addResultTuple
public boolean addResultTuple(Tuple tuple)
Add a tuple to the result.- Parameters:
tuple
- The result node.- Returns:
- True, if could be added.
-
removeResultTuple
public boolean removeResultTuple(Tuple tuple)
Remove from the result.- Parameters:
tuple
- The tuple.- Returns:
- True, if could be removed.
-
getResultMemory
public java.util.Collection getResultMemory()
Get the result memory.- Returns:
- The result memory.
-
getObjects
public java.util.Set getObjects(Tuple tuple, ConstraintIndexer ci)
Get the indexed objects per tuple.- Parameters:
tuple
- The indexed tuple.ci
- The constraint indexer.
-
getTuples
public java.util.Set getTuples(java.lang.Object object, ConstraintIndexer ci)
Get the indexed tuples per object.- Parameters:
object
- The indexed object.ci
- The constraint indexer.
-
addObject
public void addObject(java.lang.Object value, java.lang.Object object, ConstraintIndexer ci)
Add an value -> object pair to the object index.- Parameters:
value
- The value.object
- The object.ci
- The constraint indexer.
-
removeObject
public void removeObject(java.lang.Object object, ConstraintIndexer ci)
Remove an object from the object index.- Parameters:
object
- The object.ci
- The constraint indexer.
-
addTuple
public void addTuple(java.lang.Object value, Tuple tuple, ConstraintIndexer ci)
Add an value -> object pair to the tuple index.- Parameters:
value
- The value.tuple
- The tuple.ci
- The constraint indexer.
-
removeTuple
public void removeTuple(Tuple tuple, ConstraintIndexer ci)
Remove an value -> object pair from the tuple index.- Parameters:
object
- The object.ci
- The constraint indexer.
-
getIndexedMemory
protected BetaMemory.IndexedConstraintMemory getIndexedMemory(ConstraintIndexer ci)
Get the indexed memory per constraint indexer.- Parameters:
ci
- The constraint indexer.
-
size
public int size()
Get the size of the beta memory (including indexed memories).- Returns:
- The size of the memory.
-
toString
public java.lang.String toString()
Get the string representation.- Overrides:
toString
in classjava.lang.Object
- Returns:
- The string representation.
-
-