TriggerTree class
A trigger tree organizes evaluators according to generalization/specialization in order to make it easier to use rules.
Constructors
Trigger |
Intializes a new instance of the |
Properties
comparers | A dictionary of |
optimizers | A list of |
root | The root node instance. |
total |
The total number of triggers. |
Methods
add |
Add a trigger expression to the tree. |
matches(Memory |
Return the possible matches given the current state. |
remove |
Remove trigger from tree. |
to |
|
tree |
Generates a string describing the tree. |
verify |
Verify the tree meets specialization/generalization invariants. |
Constructor Details
TriggerTree()
Intializes a new instance of the TriggerTree
class.
new TriggerTree()
Property Details
comparers
A dictionary of PredicateComparer
values, with string keys.
comparers: PredicateComparers
Property Value
optimizers
root
totalTriggers
The total number of triggers.
totalTriggers: number = 0
Property Value
number
Method Details
addTrigger(string | Expression, any, Quantifier[])
Add a trigger expression to the tree.
function addTrigger(stringOrExpression: string | Expression, action: any, quantifiers: Quantifier[]): Trigger
Parameters
- stringOrExpression
-
string | Expression
Trigger to add.
- action
-
any
Action when triggered.
- quantifiers
Quantifiers to use when expanding expressions.
Returns
New trigger.
matches(MemoryInterface | any)
Return the possible matches given the current state.
function matches(state: MemoryInterface | any): Trigger[]
Parameters
- state
-
MemoryInterface | any
State to evaluate against.
Returns
Trigger[]
List of possible matches.
removeTrigger(Trigger)
Remove trigger from tree.
function removeTrigger(trigger: Trigger): boolean
Parameters
- trigger
- Trigger
Trigger to remove.
Returns
boolean
True if removed trigger.
toString()
function toString(): string
Returns
string
A string the represents the current object.
treeToString(number)
Generates a string describing the tree.
function treeToString(indent: number): string
Parameters
- indent
-
number
Current indent level.
Returns
string
String describing the tree.
verifyTree()
Verify the tree meets specialization/generalization invariants.
function verifyTree(): Node
Returns
Bad node if found.